/
Select.tsx
64 lines (60 loc) · 2.06 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React from 'react'
import ReactSelect from 'react-select'
import { useTheme } from 'styled-components'
const Select = props => {
const theme = useTheme()
const styles = {
control: (styles, { isFocused }) => {
return {
...styles,
backgroundColor: theme.colors.inputBackground,
borderColor: isFocused ? theme.colors.accent : theme.colors.border,
marginBottom: '5px',
boxShadow: isFocused ? `0 0 0 1px ${theme.colors.accent}` : null,
'&:hover': {
borderColor: isFocused ? theme.colors.accent : theme.colors.border,
},
}
},
menu: styles => {
return {
...styles,
backgroundColor: theme.colors.cardBackground,
}
},
option: (styles, { isSelected, isFocused, isDisabled }) => {
return {
...styles,
backgroundColor: isSelected
? theme.colors.accent
: isFocused
? theme.colors.background
: 'transparent',
color: isDisabled ? theme.colors.textLight : isSelected ? 'white' : 'inherit',
':active': {
backgroundColor: isSelected ? theme.colors.accent : theme.colors.background,
},
}
},
singleValue: (styles, { isDisabled }) => {
return {
...styles,
color: isDisabled ? theme.colors.textLight : theme.colors.text,
}
},
indicatorSeparator: (styles, { isDisabled }) => {
return {
...styles,
background: isDisabled ? 'rgba(0,0,0,0)' : theme.colors.border,
}
},
dropdownIndicator: styles => {
return {
...styles,
color: theme.colors.border,
}
},
}
return <ReactSelect styles={styles} {...props} />
}
export default Select