|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 | 16 |
|
17 |
| -export const CommonGroupedDropdownStyles = { |
| 17 | +import { components, DropdownIndicatorProps, StylesConfig } from 'react-select' |
| 18 | +import { ReactComponent as DropDownIcon } from '@Icons/ic-chevron-down.svg' |
| 19 | + |
| 20 | +export const CommonGroupedDropdownStyles: StylesConfig = { |
18 | 21 | container: (base, state) => ({
|
19 | 22 | ...base,
|
20 | 23 | ...(state.isDisabled && {
|
@@ -109,3 +112,85 @@ export const CommonGroupedDropdownStyles = {
|
109 | 112 | backgroundColor: 'var(--bg-primary)',
|
110 | 113 | }),
|
111 | 114 | }
|
| 115 | + |
| 116 | +export const APP_SELECTOR_STYLES: StylesConfig = { |
| 117 | + control: (base, state) => ({ |
| 118 | + ...base, |
| 119 | + border: state.menuIsOpen ? '1px solid var(--B500)' : 'unset', |
| 120 | + boxShadow: 'none', |
| 121 | + color: 'var(--N900)', |
| 122 | + minHeight: '32px', |
| 123 | + minWidth: state.menuIsOpen ? '300px' : 'unset', |
| 124 | + justifyContent: state.menuIsOpen ? 'space-between' : 'flex-start', |
| 125 | + cursor: 'pointer', |
| 126 | + backgroundColor: 'var(--bg-primary)', |
| 127 | + }), |
| 128 | + valueContainer: (base, state) => ({ |
| 129 | + ...base, |
| 130 | + display: 'flex', |
| 131 | + flexDirection: 'row-reverse', |
| 132 | + flexBasis: '0px', |
| 133 | + justifyContent: 'flex-end', |
| 134 | + padding: state.selectProps.menuIsOpen ? '0 0 0 4px' : '0', |
| 135 | + color: state.selectProps.menuIsOpen ? 'var(--N500)' : 'var(--N900)', |
| 136 | + height: '30px', |
| 137 | + }), |
| 138 | + singleValue: (base, state) => ({ |
| 139 | + ...base, |
| 140 | + color: state.selectProps.menuIsOpen ? 'var(--N500)' : 'var(--N900)', |
| 141 | + }), |
| 142 | + menu: (base) => ({ |
| 143 | + ...base, |
| 144 | + backgroundColor: 'var(--bg-primary)', |
| 145 | + minWidth: '300px', |
| 146 | + fontSize: '14px', |
| 147 | + fontWeight: 'normal', |
| 148 | + }), |
| 149 | + menuList: (base) => ({ |
| 150 | + ...base, |
| 151 | + padding: '8px', |
| 152 | + }), |
| 153 | + option: (base, state) => ({ |
| 154 | + ...base, |
| 155 | + borderRadius: '4px', |
| 156 | + color: state.isSelected ? 'var(--B500)' : 'var(--N900)', |
| 157 | + // eslint-disable-next-line no-nested-ternary |
| 158 | + backgroundColor: state.isSelected ? 'var(--B100)' : state.isFocused ? 'var(--N100)' : 'var(--bg-primary)', |
| 159 | + fontWeight: state.isSelected ? 600 : 'normal', |
| 160 | + marginRight: '8px', |
| 161 | + }), |
| 162 | + input: (base) => ({ |
| 163 | + ...base, |
| 164 | + margin: '0', |
| 165 | + flex: 'unset', |
| 166 | + color: 'var(--N900)', |
| 167 | + }), |
| 168 | + dropdownIndicator: (base) => ({ |
| 169 | + ...base, |
| 170 | + padding: '0 4px 0 4px', |
| 171 | + }), |
| 172 | +} |
| 173 | + |
| 174 | +export const AppSelectorDropdownIndicator = (props: DropdownIndicatorProps) => { |
| 175 | + const { selectProps } = props |
| 176 | + |
| 177 | + return ( |
| 178 | + <components.DropdownIndicator {...props}> |
| 179 | + <DropDownIcon |
| 180 | + className="rotate" |
| 181 | + style={{ |
| 182 | + ['--rotateBy' as any]: selectProps.menuIsOpen ? '180deg' : '0deg', |
| 183 | + height: '24px', |
| 184 | + width: '24px', |
| 185 | + }} |
| 186 | + /> |
| 187 | + </components.DropdownIndicator> |
| 188 | + ) |
| 189 | +} |
| 190 | + |
| 191 | +export const AppSelectorNoOptionsMessage = (inputObj: { inputValue: string }): string => { |
| 192 | + if (inputObj && (inputObj.inputValue === '' || inputObj.inputValue.length < 3)) { |
| 193 | + return 'Type 3 chars to see matching results' |
| 194 | + } |
| 195 | + return 'No matching results' |
| 196 | +} |
0 commit comments