Skip to content

Commit bda98c8

Browse files
committedJan 12, 2022
feat(website): fix components explorer filtering
1 parent 16f89bb commit bda98c8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎website/src/components/components/explorer/ComponentsGrid.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styled from 'styled-components'
33
import { ComponentsGridItem } from './ComponentsGridItem'
44
import * as nav from '../../../data/nav'
55
import media from '../../../theming/mediaQueries'
6-
import { ChartNavData } from '../../../types'
6+
import { ChartNavData, Flavor } from '../../../types'
77

88
type FilterFunction = (item: ChartNavData) => boolean
99

@@ -13,9 +13,11 @@ const getFilterFunction = (term?: string | null, filter?: string | null): Filter
1313
predicates.push(({ name }) => name.toLowerCase().includes(term.toLowerCase()))
1414
}
1515
if (filter) {
16-
// @ts-ignore
17-
predicates.push(({ flavors }) => flavors[filter.toLowerCase()] === true)
18-
predicates.push(({ tags }) => tags.includes(filter))
16+
const normalizedFilter = filter.toLowerCase()
17+
predicates.push(({ tags, flavors }) => {
18+
if (tags.includes(normalizedFilter)) return true
19+
return !!(normalizedFilter in flavors && flavors[normalizedFilter as Flavor])
20+
})
1921
}
2022

2123
return item => predicates.every(predicate => predicate(item))

0 commit comments

Comments
 (0)
Please sign in to comment.