mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-05 08:00:52 +08:00
[questions][fix] tweak question filters (#452)
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { useMemo } from 'react';
|
||||
import type { UseFormRegisterReturn } from 'react-hook-form';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { CheckboxInput, Collapsible, RadioList } from '@tih/ui';
|
||||
import { CheckboxInput, CheckboxList, Collapsible, RadioList } from '@tih/ui';
|
||||
|
||||
export type FilterChoice<V extends string = string> = {
|
||||
id: string;
|
||||
@ -96,7 +96,7 @@ export default function FilterSection<V extends string>({
|
||||
<Collapsible defaultOpen={true} label={collapsibleLabel}>
|
||||
<div className="-mx-2 flex flex-col items-stretch gap-2">
|
||||
{!showAll && (
|
||||
<div className="z-10">
|
||||
<div>
|
||||
{renderInput({
|
||||
field,
|
||||
onOptionChange: async (option: FilterOption<V>) => {
|
||||
@ -110,8 +110,8 @@ export default function FilterSection<V extends string>({
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{isSingleSelect ? (
|
||||
<div className="px-1.5">
|
||||
<div className="px-1.5">
|
||||
{isSingleSelect ? (
|
||||
<RadioList
|
||||
isLabelHidden={true}
|
||||
label={label}
|
||||
@ -133,26 +133,26 @@ export default function FilterSection<V extends string>({
|
||||
/>
|
||||
))}
|
||||
</RadioList>
|
||||
</div>
|
||||
) : (
|
||||
<div className="px-1.5">
|
||||
{options
|
||||
.filter((option) => showAll || option.checked)
|
||||
.map((option) => (
|
||||
<CheckboxInput
|
||||
key={option.value}
|
||||
label={option.label}
|
||||
value={option.checked}
|
||||
onChange={(checked) => {
|
||||
onOptionChange({
|
||||
...option,
|
||||
checked,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
) : (
|
||||
<CheckboxList isLabelHidden={true} label={label}>
|
||||
{options
|
||||
.filter((option) => showAll || option.checked)
|
||||
.map((option) => (
|
||||
<CheckboxInput
|
||||
key={option.value}
|
||||
label={option.label}
|
||||
value={option.checked}
|
||||
onChange={(checked) => {
|
||||
onOptionChange({
|
||||
...option,
|
||||
checked,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</CheckboxList>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Collapsible>
|
||||
</div>
|
||||
|
@ -14,6 +14,9 @@ export default {
|
||||
description: {
|
||||
control: 'text',
|
||||
},
|
||||
isLabelHidden: {
|
||||
control: 'boolean',
|
||||
},
|
||||
label: {
|
||||
control: 'text',
|
||||
},
|
||||
|
Reference in New Issue
Block a user