Skip to content

Commit 369f0ca

Browse files
committed
chore: move app selector react select styles from dashboard
1 parent e3a4b32 commit 369f0ca

File tree

2 files changed

+87
-1
lines changed

2 files changed

+87
-1
lines changed

src/Common/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export const URLS = {
8383
CONFIG_DRIFT: 'config-drift',
8484
RESOURCE_BROWSER: '/resource-browser',
8585
COMPARE_CLUSTERS: '/compare-clusters',
86+
GLOBAL_CONFIG: '/global-config',
8687
GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP,
8788
GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP_CREATE: `${GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP}/create`,
8889
GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP_DETAIL: `${GLOBAL_CONFIG_TEMPLATES_DEVTRON_APP}/detail/:appId`,

src/Shared/Components/ReactSelect/constants.ts renamed to src/Shared/Components/ReactSelect/constants.tsx

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

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 = {
1821
container: (base, state) => ({
1922
...base,
2023
...(state.isDisabled && {
@@ -109,3 +112,85 @@ export const CommonGroupedDropdownStyles = {
109112
backgroundColor: 'var(--bg-primary)',
110113
}),
111114
}
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

Comments
 (0)