-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added show more for top tags component
- Loading branch information
Oleksandr Holub
committed
Dec 7, 2023
1 parent
4e6f1d8
commit 321fbc6
Showing
6 changed files
with
57 additions
and
43 deletions.
There are no files selected for viewing
31 changes: 0 additions & 31 deletions
31
client/src/components/LinkListToolbar/components/TopTagsList.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...nents/LinkListToolbar/LinkListToolbar.tsx → ...kList/LinkListToolbar/LinkListToolbar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
15
...Toolbar/components/SearchByTitleInput.tsx → ...Toolbar/components/SearchByTitleInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
client/src/screens/LinkList/LinkListToolbar/components/TopTagsList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {observer} from 'mobx-react-lite'; | ||
import Skeleton from '../../../../components/Skeleton.tsx'; | ||
import TagBadge from '../../../../components/TagBadge.tsx'; | ||
import {useLinkStore} from '../../../../contexts/AppContext.tsx'; | ||
import {useMemo, useState} from 'react'; | ||
|
||
const MaxTagsShown = 6; | ||
|
||
const TopTagsList = observer(() => { | ||
const { sortedTags, state: { tags, filter: { tags: appliedTags }, isListLoading }, toggleTagFilter } = useLinkStore(); | ||
const [showAll, setShowAll] = useState(false); | ||
const tagList = useMemo(() => showAll ? sortedTags : sortedTags.slice(0, MaxTagsShown), [showAll, sortedTags]); | ||
|
||
const showSkeletons = isListLoading && tags.length === 0; | ||
return ( | ||
<> | ||
{ showSkeletons && ( | ||
<div className="flex flex-col justify-center items-center w-full gap-2"> | ||
<Skeleton className="w-full" /> | ||
<Skeleton className="w-full" /> | ||
</div> | ||
) || <div className="flex flex-row flex-wrap justify-center gap-3 items-center"> | ||
{ appliedTags.map((tag) => ( | ||
<TagBadge key={tag} onClick={() => toggleTagFilter(tag)} name={tag} removable active /> | ||
))} | ||
{ tagList.filter(x => !appliedTags.some(e => e === x.name)).map((tag) => ( | ||
<TagBadge key={tag.name} {...tag} onClick={() => toggleTagFilter(tag.name)} /> | ||
)) } | ||
{ !showAll && sortedTags.length > MaxTagsShown && ( | ||
<button onClick={() => setShowAll(true)} className="py-1 font-semibold text-zinc-500 hover:text-zinc-300"> | ||
show more | ||
</button> | ||
)} | ||
{ showAll && ( | ||
<button onClick={() => setShowAll(false)} className="py-1 font-semibold text-zinc-500 hover:text-zinc-300"> | ||
show less | ||
</button> | ||
)} | ||
</div>} | ||
</> | ||
); | ||
}); | ||
|
||
export default TopTagsList; |
4 changes: 2 additions & 2 deletions
4
...bar/components/UserInteractionsFilter.tsx → ...bar/components/UserInteractionsFilter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters