forked from webxdc/webxdc-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFilter.tsx
50 lines (47 loc) · 1.12 KB
/
Filter.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import {
Select,
SelectTrigger,
SelectPlaceholder,
SelectValue,
SelectIcon,
SelectContent,
SelectListbox,
SelectOption,
SelectOptionText,
SelectOptionIndicator,
} from "@hope-ui/solid";
import type { Component } from "solid-js";
import { For } from "solid-js";
export type FilterEntry = {
text: string;
value: string;
};
const Filter: Component<{
label: string;
entries: FilterEntry[];
value: string;
onChange: (value: string) => void;
}> = (props) => {
return (
<Select size="xs" value={props.value} onChange={props.onChange}>
<SelectTrigger>
<SelectPlaceholder>{props.label}</SelectPlaceholder>
<SelectValue />
<SelectIcon />
</SelectTrigger>
<SelectContent>
<SelectListbox>
<For each={props.entries}>
{(entry) => (
<SelectOption value={entry.value}>
<SelectOptionText>{entry.text}</SelectOptionText>
<SelectOptionIndicator />
</SelectOption>
)}
</For>
</SelectListbox>
</SelectContent>
</Select>
);
};
export default Filter;