diff --git a/src/components/MaintainersDirectoryFilters.tsx b/src/components/MaintainersDirectoryFilters.tsx index 7f72a4df1..8109c6e2c 100644 --- a/src/components/MaintainersDirectoryFilters.tsx +++ b/src/components/MaintainersDirectoryFilters.tsx @@ -1,8 +1,15 @@ +import { Popover } from '@base-ui/react/popover' import { Select } from '@base-ui/react/select' -import { CaretDownIcon, CheckIcon } from '@phosphor-icons/react' +import { + CaretDownIcon, + CheckIcon, + FunnelIcon, + type Icon, +} from '@phosphor-icons/react' import * as v from 'valibot' import { libraries } from '~/libraries' import { frameworkOptions } from '~/libraries/frameworks' +import { fallbackLibraryIcon, libraryIcons } from '~/libraries/icons' import { allMaintainers } from '~/libraries/maintainers' import { libraryIdSchema } from '~/utils/schemas' @@ -68,7 +75,7 @@ function FilterSelect< 'multiple' | 'value' | 'onValueChange' > & { label: string - choices: ReadonlyArray<{ value: TValue; label: string }> + choices: ReadonlyArray<{ value: TValue; label: string; icon?: Icon }> }) { const selectionCount = Array.isArray(selection.value) ? selection.value.length @@ -101,16 +108,23 @@ function FilterSelect< > - {choices.map(({ value, label }) => ( + {choices.map(({ value, label, icon: ItemIcon }) => ( - + {ItemIcon && ( + ))} @@ -138,73 +152,101 @@ export function MaintainersDirectoryFilters({ .map(({ id, name }) => ({ value: id, label: name.replace(/^TanStack /, ''), + icon: libraryIcons[id] ?? fallbackLibraryIcon, })) + const hasAdvancedFilters = + !!search.frameworks?.length || + !!search.specialties?.length || + search.groupBy !== 'none' || + search.sortBy !== 'none' + return (
-
-
- - onChange({ libraries: libraries.length ? libraries : undefined }) - } - /> - - onChange({ - frameworks: frameworks.length ? frameworks : undefined, - }) - } - /> - - onChange({ - specialties: specialties.length ? specialties : undefined, - }) - } - /> - - onChange({ groupBy: groupBy ?? 'none' }) - } - /> - onChange({ sortBy: sortBy ?? 'none' })} - /> -
+
+ + onChange({ libraries: libraries.length ? libraries : undefined }) + } + />
- {clearAll && ( -
- -
- )} + + + + + + + Filter and sort +
+ + onChange({ + frameworks: frameworks.length ? frameworks : undefined, + }) + } + /> + + onChange({ + specialties: specialties.length ? specialties : undefined, + }) + } + /> + + onChange({ groupBy: groupBy ?? 'none' }) + } + /> + + onChange({ sortBy: sortBy ?? 'none' }) + } + /> + {clearAll && ( + + )} +
+
+
+
+
) }