mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-28 19:42:01 +03:00
feat: add show more/less
This commit is contained in:
parent
a392ad9707
commit
743fa736e9
@ -192,6 +192,20 @@ const STYLES_TAG = css`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const STYLES_SHOW_MORE = css`
|
||||||
|
font-family: ${Constants.font.text};
|
||||||
|
color: ${Constants.system.textGray};
|
||||||
|
font-size: 14px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin: 10px 0 0;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
span {
|
||||||
|
margin: 0 0 0 8px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
const DeleteConfirmation = ({ tag, handleDelete }) => {
|
const DeleteConfirmation = ({ tag, handleDelete }) => {
|
||||||
const [deleteConfirmed, setDeleteConfirmation] = React.useState(false);
|
const [deleteConfirmed, setDeleteConfirmation] = React.useState(false);
|
||||||
|
|
||||||
@ -350,6 +364,9 @@ export const Tag = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [value, setValue] = React.useState("");
|
const [value, setValue] = React.useState("");
|
||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = React.useState(false);
|
||||||
|
const [showMore, setShowMore] = React.useState(false);
|
||||||
|
|
||||||
|
const numToDisplay = showMore ? tags.length : 15;
|
||||||
|
|
||||||
const _handleRemove = (tag) => {
|
const _handleRemove = (tag) => {
|
||||||
const newTags = [...tags];
|
const newTags = [...tags];
|
||||||
@ -404,12 +421,23 @@ export const Tag = ({
|
|||||||
|
|
||||||
<ul css={STYLES_LIST}>
|
<ul css={STYLES_LIST}>
|
||||||
{tags &&
|
{tags &&
|
||||||
tags.map((tag) => (
|
tags.slice(0, numToDisplay).map((tag) => (
|
||||||
<li key={tag} css={STYLES_TAG}>
|
<li key={tag} css={STYLES_TAG}>
|
||||||
<span>{tag}</span>
|
<span>{tag}</span>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
{tags.length > 15 && (
|
||||||
|
<p css={STYLES_SHOW_MORE} onClick={() => setShowMore(!showMore)}>
|
||||||
|
<SVG.ChevronDown
|
||||||
|
height="16px"
|
||||||
|
style={{ transform: `rotate(${showMore ? 180 : 0}deg)`, transition: "200ms ease all" }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<span>{!showMore ? "show all" : "show less"}</span>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user