Skip to content

Commit 2a169f4

Browse files
committed
Improve [Clear Filters] button
1 parent b6e8cbe commit 2a169f4

File tree

2 files changed

+60
-29
lines changed

2 files changed

+60
-29
lines changed

src/app/conf/2025/schedule/_components/filters.tsx

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
import clsx from "clsx"
22
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"
37

48
import CloseIcon from "@/app/conf/2025/pixelarticons/close.svg?svgr"
59
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"
810
import { eventsColors } from "../../utils"
9-
1011
type FiltersProps = {
1112
categories: { name: string; options: string[] }[]
1213
filterState: Record<string, string[]>
1314
onFilterChange: (category: string, newSelectedOptions: string[]) => void
14-
onReset: () => void
1515
}
1616

1717
export 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
)

src/app/conf/2025/schedule/_components/schedule-list.tsx

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ReactElement, useEffect, useState } from "react"
66
import { getEventTitle } from "@/app/conf/2023/utils"
77
import { SchedSpeaker } from "@/app/conf/2023/types"
88

9-
import { Filters } from "./filters"
9+
import { Filters, ResetFiltersButton } from "./filters"
1010
import {
1111
type ScheduleSession,
1212
CategoryName,
@@ -119,6 +119,19 @@ export function ScheduleList({
119119

120120
return (
121121
<>
122+
<div className="flex justify-between gap-1 max-lg:flex-col">
123+
<BookmarkOnSched />
124+
<ResetFiltersButton
125+
filters={filtersState}
126+
onReset={() =>
127+
setFiltersState({
128+
Audience: [],
129+
"Talk category": [],
130+
"Event type": [],
131+
})
132+
}
133+
/>
134+
</div>
122135
{showFilter && (
123136
<Filters
124137
categories={filterCategories}
@@ -129,13 +142,6 @@ export function ScheduleList({
129142
[category]: newSelectedOptions,
130143
}))
131144
}}
132-
onReset={() => {
133-
setFiltersState({
134-
Audience: [],
135-
"Talk category": [],
136-
"Event type": [],
137-
})
138-
}}
139145
/>
140146
)}
141147
{Object.entries(sessionsState).length === 0 ? (
@@ -270,3 +276,27 @@ function ScheduleSession({
270276
</a>
271277
)
272278
}
279+
280+
function BookmarkOnSched() {
281+
return (
282+
<a
283+
href="https://graphqlconf2024.sched.com"
284+
target="_blank"
285+
rel="noreferrer"
286+
className="mb-8 block w-fit decoration-neu-400 typography-link"
287+
>
288+
Bookmark sessions & plan your days on Sched
289+
<svg
290+
fill="none"
291+
xmlns="http://www.w3.org/2000/svg"
292+
viewBox="0 0 24 24"
293+
className="m-1 mb-2 inline-block size-4"
294+
>
295+
<path
296+
d="M21 11V3h-8v2h4v2h-2v2h-2v2h-2v2H9v2h2v-2h2v-2h2V9h2V7h2v4h2zM11 5H3v16h16v-8h-2v6H5V7h6V5z"
297+
fill="currentColor"
298+
/>
299+
</svg>
300+
</a>
301+
)
302+
}

0 commit comments

Comments
 (0)