1
1
import clsx from "clsx"
2
2
import { 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"
3
7
4
8
import CloseIcon from "@/app/conf/2025/pixelarticons/close.svg?svgr"
5
9
import 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"
8
10
import { eventsColors } from "../../utils"
9
-
10
11
type FiltersProps = {
11
12
categories : { name : string ; options : string [ ] } [ ]
12
13
filterState : Record < string , string [ ] >
13
14
onFilterChange : ( category : string , newSelectedOptions : string [ ] ) => void
14
- onReset : ( ) => void
15
15
}
16
16
17
17
export function Filters ( {
18
18
categories,
19
19
filterState,
20
20
onFilterChange,
21
- onReset,
22
21
} : FiltersProps ) {
23
22
return (
24
23
< div className = "flex flex-wrap justify-stretch gap-x-2 gap-y-4 pb-10" >
@@ -35,33 +34,35 @@ export function Filters({
35
34
className = "flex-1"
36
35
/>
37
36
) ) }
38
- { Object . values ( filterState ) . flat ( ) . length > 0 && (
39
- < div className = "relative" >
40
- < ResetButton onReset = { onReset } className = "absolute top-[18px]" />
41
- </ div >
42
- ) }
43
37
</ div >
44
38
)
45
39
}
46
40
47
- function ResetButton ( {
41
+ export function ResetFiltersButton ( {
48
42
onReset,
49
43
className,
44
+ filters,
50
45
} : {
46
+ filters : Record < string , string [ ] >
51
47
onReset : ( ) => void
52
48
className ?: string
53
49
} ) {
50
+ const hasFilters = Object . values ( filters ) . flat ( ) . length > 0
51
+
54
52
return (
55
- < button
53
+ < Button
54
+ variant = "tertiary"
56
55
title = "Reset filters"
57
56
onClick = { onReset }
57
+ disabled = { ! hasFilters }
58
58
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 " ,
60
60
className ,
61
61
) }
62
62
>
63
+ Clear filters
63
64
< CloseIcon className = "inline-block size-4" />
64
- </ button >
65
+ </ Button >
65
66
)
66
67
}
67
68
@@ -180,14 +181,14 @@ function CheckboxIcon({ checked, ...rest }: CheckboxIconProps) {
180
181
/>
181
182
</ >
182
183
) : (
183
- < >
184
+ < g className = "[&>path]:fill-neu-0" >
184
185
< 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 >
191
192
) }
192
193
</ svg >
193
194
)
0 commit comments