11import clsx from "clsx"
22import { useState } from "react"
3+ import { Combobox } from "@headlessui/react"
4+
5+ import { Tag } from "@/app/conf/_design-system/tag"
6+ import { Button } from "@/app/conf/_design-system/button"
37
48import CloseIcon from "@/app/conf/2025/pixelarticons/close.svg?svgr"
59import CaretDownIcon from "@/app/conf/2025/pixelarticons/caret-down.svg?svgr"
6- import { Combobox } from "@headlessui/react"
7- import { Tag } from "@/app/conf/_design-system/tag"
810import { eventsColors } from "../../utils"
9-
1011type FiltersProps = {
1112 categories : { name : string ; options : string [ ] } [ ]
1213 filterState : Record < string , string [ ] >
1314 onFilterChange : ( category : string , newSelectedOptions : string [ ] ) => void
14- onReset : ( ) => void
1515}
1616
1717export function Filters ( {
1818 categories,
1919 filterState,
2020 onFilterChange,
21- onReset,
2221} : FiltersProps ) {
2322 return (
2423 < div className = "flex flex-wrap justify-stretch gap-x-2 gap-y-4 pb-10" >
@@ -35,33 +34,35 @@ export function Filters({
3534 className = "flex-1"
3635 />
3736 ) ) }
38- { Object . values ( filterState ) . flat ( ) . length > 0 && (
39- < div className = "relative" >
40- < ResetButton onReset = { onReset } className = "absolute top-[18px]" />
41- </ div >
42- ) }
4337 </ div >
4438 )
4539}
4640
47- function ResetButton ( {
41+ export function ResetFiltersButton ( {
4842 onReset,
4943 className,
44+ filters,
5045} : {
46+ filters : Record < string , string [ ] >
5147 onReset : ( ) => void
5248 className ?: string
5349} ) {
50+ const hasFilters = Object . values ( filters ) . flat ( ) . length > 0
51+
5452 return (
55- < button
53+ < Button
54+ variant = "tertiary"
5655 title = "Reset filters"
5756 onClick = { onReset }
57+ disabled = { ! hasFilters }
5858 className = { clsx (
59- "flex h-fit cursor-pointer items-center gap-x-2 bg-neu-100 p-2 text-neu-700 hover:bg-neu-200/80 hover:text-neu-900" ,
59+ "h-fit items-center gap-x-2 bg-neu-100 ! p-2 text-neu-700 transition-opacity hover:bg-neu-200/80 hover:text-neu-900 disabled:opacity-0 " ,
6060 className ,
6161 ) }
6262 >
63+ Clear filters
6364 < CloseIcon className = "inline-block size-4" />
64- </ button >
65+ </ Button >
6566 )
6667}
6768
@@ -180,14 +181,14 @@ function CheckboxIcon({ checked, ...rest }: CheckboxIconProps) {
180181 />
181182 </ >
182183 ) : (
183- < >
184+ < g className = "[&>path]:fill-neu-0" >
184185 < rect x = "2" y = "3" width = "15" height = "15" />
185- < path d = "M6 10.3333H7.66667V12H6V10.3333Z" fill = "white" />
186- < path d = "M7.66667 12H9.33333V13.6667H7.66667V12Z" fill = "white" />
187- < path d = "M9.33333 10.3333H11V12H9.33333V10.3333Z" fill = "white" />
188- < path d = "M11 8.66667H12.6667V10.3333H11V8.66667Z" fill = "white" />
189- < path d = "M12.6667 7H14.3333V8.66667H12.6667V7Z" fill = "white" />
190- </ >
186+ < path d = "M6 10.3333H7.66667V12H6V10.3333Z" />
187+ < path d = "M7.66667 12H9.33333V13.6667H7.66667V12Z" />
188+ < path d = "M9.33333 10.3333H11V12H9.33333V10.3333Z" />
189+ < path d = "M11 8.66667H12.6667V10.3333H11V8.66667Z" />
190+ < path d = "M12.6667 7H14.3333V8.66667H12.6667V7Z" />
191+ </ g >
191192 ) }
192193 </ svg >
193194 )
0 commit comments