|
1 | 1 | import systemColors from 'src/Styles/colors'; |
2 | 2 |
|
| 3 | +export const SELECT_SIZES = { SMALL: 'small' }; |
| 4 | + |
| 5 | +const getHeightProps = (size) => { |
| 6 | + if (size === SELECT_SIZES.SMALL) { |
| 7 | + return { |
| 8 | + height: '2.25rem', |
| 9 | + minHeight: '2.25rem', |
| 10 | + }; |
| 11 | + } |
| 12 | + return null; |
| 13 | +}; |
| 14 | + |
3 | 15 | /* |
4 | 16 | To set styles for your item, make sure your option object has a child `colors` object |
5 | 17 | with a text and/or hover key defined to override the defaults |
6 | 18 | */ |
7 | | -const defaultStyles = { |
8 | | - control: (styles, { isDisabled }) => ({ |
9 | | - ...styles, |
10 | | - backgroundColor: isDisabled ? systemColors.inputDisabledBg : styles.backgroundColor, |
11 | | - borderColor: systemColors.inputBorderColor, |
12 | | - }), |
13 | | - indicatorSeparator: (styles) => ({ ...styles, display: 'none' }), |
14 | | - singleValue: (styles, { data }) => ({ |
15 | | - ...styles, |
16 | | - color: (data.colors ? data.colors.text : systemColors.uxGray600) || systemColors.uxGray600, |
17 | | - }), |
18 | | - option: (styles, { |
19 | | - data, |
20 | | - isDisabled, |
21 | | - isFocused, |
22 | | - isSelected, |
23 | | - }) => { |
24 | | - const colors = data.colors || {}; |
25 | | - |
26 | | - return { |
| 19 | +const defaultStyles = ({ size }) => ({ |
| 20 | + control: (styles, { isDisabled }) => ({ |
27 | 21 | ...styles, |
28 | | - backgroundColor: isSelected || isFocused ? colors.hover : styles.backgroundColor, |
29 | | - color: colors.text, |
30 | | - cursor: 'pointer', |
31 | | - |
32 | | - ':active': { |
33 | | - ...styles[':active'], |
34 | | - backgroundColor: |
35 | | - !isDisabled && isSelected ? systemColors.uxGray200 : styles[':active'].backgroundColor, |
36 | | - }, |
37 | | - |
38 | | - ':hover': { |
39 | | - ...styles[':hover'], |
40 | | - backgroundColor: colors.hover || systemColors.uxGray200, |
41 | | - }, |
42 | | - }; |
43 | | - }, |
44 | | -}; |
| 22 | + ...getHeightProps(size), |
| 23 | + backgroundColor: isDisabled ? systemColors.inputDisabledBg : styles.backgroundColor, |
| 24 | + borderColor: systemColors.inputBorderColor, |
| 25 | + }), |
| 26 | + indicatorSeparator: (styles) => ({ ...styles, display: 'none' }), |
| 27 | + singleValue: (styles, { data }) => ({ |
| 28 | + ...styles, |
| 29 | + color: (data.colors ? data.colors.text : systemColors.uxGray600) || systemColors.uxGray600, |
| 30 | + }), |
| 31 | + option: (styles, { |
| 32 | + data, |
| 33 | + isDisabled, |
| 34 | + isFocused, |
| 35 | + isSelected, |
| 36 | + }) => { |
| 37 | + const colors = data.colors || {}; |
| 38 | + |
| 39 | + return { |
| 40 | + ...styles, |
| 41 | + backgroundColor: isSelected || isFocused ? colors.hover : styles.backgroundColor, |
| 42 | + color: colors.text, |
| 43 | + cursor: 'pointer', |
| 44 | + |
| 45 | + ':active': { |
| 46 | + ...styles[':active'], |
| 47 | + backgroundColor: |
| 48 | + !isDisabled && isSelected ? systemColors.uxGray200 : styles[':active'].backgroundColor, |
| 49 | + }, |
| 50 | + |
| 51 | + ':hover': { |
| 52 | + ...styles[':hover'], |
| 53 | + backgroundColor: colors.hover || systemColors.uxGray200, |
| 54 | + }, |
| 55 | + }; |
| 56 | + }, |
| 57 | +}); |
45 | 58 |
|
46 | 59 | const defaultTheme = (theme) => ({ |
47 | 60 | ...theme, |
|
0 commit comments