-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: create topic category tags * feat: use real data when showing topic category tags * feat: add topic category data to resource page * feat: associate topic category with a Chakra UI colour * feat: sort topic categories alphabetically on resource page * chore: make icon optional in metadata block * chore: make icon optional in metadata tag + add glyph property to metadata content * feat: add EDAM onthology links to resource page * chore: remove unneeded code * refactor: remove object added to schema definitions file * refactor: send data.topicCategory to TopicCategory component * fix: filter out objects without topic name * fix: ensure only topics with name are shown on resource page * feat: add link to search to topic category tags * fix: show empty state when taxonomy is missing name --------- Co-authored-by: candicecz <[email protected]>
- Loading branch information
1 parent
872f9f8
commit 32c4c5c
Showing
8 changed files
with
170 additions
and
21 deletions.
There are no files selected for viewing
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
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
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
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
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
59 changes: 59 additions & 0 deletions
59
src/components/search-results-page/components/card/topic-category/index.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,59 @@ | ||
import React from 'react'; | ||
import NextLink from 'next/link'; | ||
import { Stack, Flex, Tag, TagLabel, TagLeftIcon } from '@chakra-ui/react'; | ||
import { TopicCategory } from 'src/utils/api/types'; | ||
import { encodeString } from 'src/utils/querystring-helpers'; | ||
import { FaMagnifyingGlass } from 'react-icons/fa6'; | ||
|
||
interface TopicCategoryProps { | ||
data?: TopicCategory[] | null; | ||
} | ||
|
||
const TopicCategories: React.FC<TopicCategoryProps> = ({ data }) => { | ||
const topicCategoryNames = data | ||
?.filter(element => element.name !== undefined) | ||
.map(element => element.name!) | ||
.sort(); | ||
const paddingCard = [4, 6, 8, 10]; | ||
if (topicCategoryNames?.length === 0) return null; | ||
return ( | ||
<Stack | ||
my='0' | ||
px={paddingCard} | ||
py='2' | ||
borderBottom='1px solid' | ||
borderBottomColor='gray.200' | ||
> | ||
<Flex flexWrap='wrap'> | ||
{topicCategoryNames?.map(name => { | ||
return ( | ||
<NextLink | ||
key={name} | ||
href={{ | ||
pathname: '/search', | ||
query: { | ||
q: `topicCategory.name:"${encodeString(name.trim())}"`, | ||
advancedSearch: true, | ||
}, | ||
}} | ||
> | ||
<Tag | ||
size='sm' | ||
variant='subtle' | ||
m='0.5' | ||
colorScheme='primary' | ||
cursor='pointer' | ||
_hover={{ textDecoration: 'underline' }} | ||
> | ||
<TagLeftIcon as={FaMagnifyingGlass} /> | ||
<TagLabel>{name}</TagLabel> | ||
</Tag> | ||
</NextLink> | ||
); | ||
})} | ||
</Flex> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default TopicCategories; |
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
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