Skip to content

Commit 079ec8f

Browse files
committed
Improve filters UI
1 parent fba4436 commit 079ec8f

12 files changed

Lines changed: 54 additions & 40 deletions

web/components/comments/dropdown-menu.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { DotsHorizontalIcon } from '@heroicons/react/solid'
2-
import { Fragment, ReactNode, useState } from 'react'
3-
import { usePopper } from 'react-popper'
4-
import { Popover, Transition } from '@headlessui/react'
1+
import {DotsHorizontalIcon} from '@heroicons/react/solid'
2+
import {Fragment, ReactNode, useState} from 'react'
3+
import {usePopper} from 'react-popper'
4+
import {Popover, Transition} from '@headlessui/react'
55
import clsx from 'clsx'
66

77
export type DropdownItem = {
@@ -51,7 +51,7 @@ export default function DropdownMenu(props: {
5151
<Popover.Button
5252
ref={setReferenceElement}
5353
className={clsx(
54-
'text-ink-500 hover:text-ink-800 flex items-center',
54+
'text-ink-500 hover-bold flex items-center',
5555
buttonClass
5656
)}
5757
onClick={(e: any) => {

web/components/filters/desktop-filters.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ export function DesktopFilters(props: {
561561
/>
562562
}
563563
popoverClassName="bg-canvas-50"
564-
menuWidth="w-50 max-h-[400px] overflow-y-auto"
564+
menuWidth="w-100 max-h-[400px] overflow-y-auto"
565565
/>
566566

567567
{/* POLITICS */}
@@ -643,7 +643,7 @@ export function DesktopFilters(props: {
643643
<MbtiFilter filters={filters} updateFilter={updateFilter} />
644644
}
645645
popoverClassName="bg-canvas-50"
646-
menuWidth="w-[350px] grid-cols-2"
646+
menuWidth="w-[400px]"
647647
/>
648648

649649
{/* EDUCATION */}

web/components/filters/interest-filter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export function InterestFilter(props: {
6666
selected={filters[label] ?? []}
6767
choices={sortedChoices as any}
6868
onChange={(c) => updateFilter({[label]: c})}
69+
optionsClassName={'w-[200px] sm:w-[400px]'}
6970
/>
7071
)
7172
}

web/components/filters/language-filter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export function LanguageFilter(props: {
6666
onChange={(c) => {
6767
updateFilter({languages: c})
6868
}}
69+
optionsClassName={'w-[200px] sm:w-[400px]'}
6970
/>
7071
)
7172
}

web/components/filters/mbti-filter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function MbtiFilter(props: {
5757

5858
return (
5959
<MultiCheckbox
60-
className={'grid grid-cols-2 xs:grid-cols-4'}
60+
optionsClassName={'grid grid-cols-2 xs:grid-cols-4'}
6161
selected={filters.mbti ?? []}
6262
choices={MBTI_CHOICES as any}
6363
translationPrefix={'profile.mbti'}

web/components/filters/my-matches-toggle.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ export function MyMatchesToggle(props: {
1818
const label = t('filter.mine_toggle', 'Your filters')
1919

2020
return (
21-
<Row className={clsx('mr-2 items-center', on && 'font-semibold')}>
21+
<Row className={clsx('mr-2 items-center hover-bold', on && 'font-semibold')}>
2222
<input
2323
id={label}
2424
type="checkbox"
25-
className="border-ink-300 bg-canvas-0 dark:border-ink-500 text-primary-600 focus:ring-primary-500 h-4 w-4 rounded"
25+
className="border-ink-300 bg-canvas-0 dark:border-ink-500 text-primary-600 focus:ring-primary-500 h-4 w-4 rounded hover:bg-canvas-200"
2626
checked={on}
2727
onChange={(e) => setYourFilters(e.target.checked)}
2828
/>

web/components/filters/religion-filter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function ReligionFilter(props: {
7070
onChange={(c) => {
7171
updateFilter({religion: c})
7272
}}
73-
className={className}
73+
optionsClassName={className}
7474
/>
7575
</>
7676
)

web/components/filters/short-bio-toggle.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ export function ShortBioToggle(props: {
1919
const on = filters.shortBio || false
2020

2121
return (
22-
<Row className={clsx('mr-2 items-center', on && 'font-semibold')}>
22+
<Row className={clsx('mr-2 items-center hover-bold', on && 'font-semibold')}>
2323
<input
2424
id={label}
2525
type="checkbox"
26-
className="border-ink-300 bg-canvas-0 dark:border-ink-500 text-primary-600 focus:ring-primary-500 h-4 w-4 rounded"
26+
className="border-ink-300 bg-canvas-0 dark:border-ink-500 text-primary-600 focus:ring-primary-500 h-4 w-4 rounded hover:bg-canvas-200"
2727
checked={on}
2828
onChange={(e) => updateFilter({shortBio: e.target.checked ? true : undefined})}
2929
/>

web/components/multi-checkbox.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const MultiCheckbox = (props: {
1414
selected: string[]
1515
onChange: (selected: string[]) => void
1616
className?: string
17+
optionsClassName?: string
1718
// If provided, enables adding a new option and should persist it (e.g. to DB)
1819
// Return value can be:
1920
// - string: the stored value for the new option; label will be the input text
@@ -23,7 +24,7 @@ export const MultiCheckbox = (props: {
2324
addPlaceholder?: string
2425
translationPrefix?: string
2526
}) => {
26-
const {choices, selected, onChange, className, addOption, addPlaceholder, translationPrefix} = props
27+
const {choices, selected, onChange, className, optionsClassName, addOption, addPlaceholder, translationPrefix} = props
2728

2829
// Keep a local merged copy to allow optimistic adds while remaining in sync with props
2930
const [localChoices, setLocalChoices] = useState<{ [key: string]: string }>(choices)
@@ -125,7 +126,7 @@ export const MultiCheckbox = (props: {
125126
</Row>
126127
)}
127128

128-
<Row className={clsx('flex-wrap')}>
129+
<Row className={clsx('flex-wrap', optionsClassName)}>
129130
{filteredEntries.map(([key, value]) => (
130131
<Checkbox
131132
key={key}

web/components/widgets/checkbox.tsx

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,26 @@ export function Checkbox(props: {
1010
const { label, checked, toggle, className, disabled } = props
1111

1212
return (
13-
<div className={clsx(className, 'space-y-5 px-2 py-1 hover:bg-canvas-200 hover:rounded')}>
14-
<div className="relative flex items-center">
15-
<div className="flex h-6 items-center">
16-
<input
17-
id={label}
18-
type="checkbox"
19-
className="border-ink-300 bg-canvas-0 dark:border-ink-500 text-primary-600 focus:ring-primary-500 h-5 w-5 rounded"
20-
checked={checked}
21-
onChange={(e) => toggle(e.target.checked)}
22-
disabled={disabled}
23-
/>
24-
</div>
25-
<div className="ml-3">
26-
<label
27-
htmlFor={label}
28-
className={clsx(
29-
'whitespace-nowrap font-medium',
30-
disabled ? 'text-ink-300' : 'text-ink-700'
31-
)}
32-
>
33-
{label}
34-
</label>
35-
</div>
36-
</div>
13+
<div className={clsx(className, 'space-y-5 px-2 py-1')}>
14+
<label
15+
className={clsx('relative flex items-center cursor-pointer select-none hover-bold', disabled && 'cursor-not-allowed')}>
16+
<input
17+
id={label}
18+
type="checkbox"
19+
className="border-ink-300 bg-canvas-0 dark:border-ink-500 text-primary-600 focus:ring-primary-500 h-5 w-5 rounded hover:bg-canvas-300"
20+
checked={checked}
21+
onChange={(e) => toggle(e.target.checked)}
22+
disabled={disabled}
23+
/>
24+
<span
25+
className={clsx(
26+
'ml-3 whitespace-nowrap font-medium',
27+
disabled ? 'text-ink-300' : 'text-ink-700'
28+
)}
29+
>
30+
{label}
31+
</span>
32+
</label>
3733
</div>
3834
)
3935
}

0 commit comments

Comments
 (0)