-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselect.tsx
43 lines (41 loc) · 1.2 KB
/
select.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
import React from 'react';
import { HiChevronDown } from 'react-icons/hi';
import { IconButton, Select as ThemeSelect } from 'theme-ui';
import { SelectOption } from './select-option';
export interface DropdownProps {
onChange?: (tags: SelectOption) => void;
}
// TODO: should be refactored, see SelectAlt component
export const Select: React.FC<DropdownProps> = React.forwardRef(
({ onChange = () => '', children, ...props }) => {
return (
<ThemeSelect
{...props}
arrow={
<IconButton sx={{ ml: -30, alignSelf: 'center', pointerEvents: 'none' }}>
<HiChevronDown sx={{ fontSize: 4 }} />
</IconButton>
}
onChange={(event) => {
const optionElement = event.target.selectedOptions[0];
onChange({
id: optionElement.id,
text: optionElement.value,
});
}}
sx={{
minWidth: '10rem',
alignItems: 'center',
backgroundColor: 'muted',
border: 'none',
borderRadius: '8px',
outline: 'none',
padding: '8px 24px 8px 8px',
fontSize: '12px',
}}
>
{children}
</ThemeSelect>
);
}
);