-
Notifications
You must be signed in to change notification settings - Fork 0
/
Selector.tsx
46 lines (42 loc) · 1.12 KB
/
Selector.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
import styled from 'styled-components';
import Select from 'react-select';
import { Option } from '../lib/useSelect';
import { Dispatch, SetStateAction } from 'react';
type SelectorProps = {
options: Option[];
onSetSelectedOption: Dispatch<SetStateAction<Option>>;
selectedOption: Option;
};
export default function Selector({
options,
onSetSelectedOption,
selectedOption,
}: SelectorProps): JSX.Element {
return (
<StyledSelect
onChange={(option) => onSetSelectedOption(option as Option)}
options={options}
value={selectedOption.value !== null && selectedOption}
styles={{
singleValue: (baseStyles) => ({
...baseStyles,
color: 'rgba(217, 217, 217, 1)',
}),
option: (baseStyles, state) => ({
...baseStyles,
color: state.isFocused ? 'black' : 'rgba(217, 217, 217, 1)',
}),
input: (baseStyles) => ({
...baseStyles,
color: 'rgba(217, 217, 217, 1)',
}),
}}
/>
);
}
const StyledSelect = styled(Select)`
z-index: 1001;
&& > * {
background-color: rgba(50, 50, 50, 1);
}
`;