Skip to content

Commit 8883274

Browse files
committed
fix: rjsf styling for select
1 parent 356cbaf commit 8883274

File tree

3 files changed

+28
-77
lines changed

3 files changed

+28
-77
lines changed

src/Common/RJSF/utils.tsx

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -30,74 +30,6 @@ export const translateString = (stringToTranslate: TranslatableString, params?:
3030
}
3131
}
3232

33-
export const getCommonSelectStyle = (styleOverrides = {}) => ({
34-
menuList: (base) => ({
35-
...base,
36-
paddingTop: 0,
37-
paddingBottom: 0,
38-
cursor: 'pointer',
39-
}),
40-
control: (base, state) => ({
41-
...base,
42-
minHeight: '32px',
43-
boxShadow: 'none',
44-
backgroundColor: 'var(--bg-secondary)',
45-
border: state.isFocused ? '1px solid var(--B500)' : '1px solid var(--N200)',
46-
cursor: 'pointer',
47-
}),
48-
option: (base, state) => ({
49-
...base,
50-
color: 'var(--N900)',
51-
backgroundColor: state.isFocused ? 'var(--N100)' : 'var(--bg-primary)',
52-
padding: '10px 12px',
53-
cursor: 'pointer',
54-
}),
55-
dropdownIndicator: (base, state) => ({
56-
...base,
57-
color: 'var(--N400)',
58-
padding: '0 8px',
59-
transition: 'all .2s ease',
60-
transform: state.selectProps.menuIsOpen ? 'rotate(180deg)' : 'rotate(0deg)',
61-
}),
62-
valueContainer: (base, state) => ({
63-
...base,
64-
padding: '0 8px',
65-
fontWeight: '400',
66-
color: state.selectProps.menuIsOpen ? 'var(--N500)' : base.color,
67-
}),
68-
loadingMessage: (base) => ({
69-
...base,
70-
color: 'var(--N600)',
71-
}),
72-
noOptionsMessage: (base) => ({
73-
...base,
74-
color: 'var(--N600)',
75-
}),
76-
multiValue: (base) => ({
77-
...base,
78-
border: `1px solid var(--N200)`,
79-
borderRadius: `4px`,
80-
background: 'var(--bg-primary)',
81-
height: '28px',
82-
marginRight: '8px',
83-
padding: '2px',
84-
fontSize: '12px',
85-
}),
86-
singleValue: (base) => ({
87-
...base,
88-
color: 'var(--N900)',
89-
}),
90-
input: (base) => ({
91-
...base,
92-
color: 'var(--N900)',
93-
}),
94-
menu: (base) => ({
95-
...base,
96-
backgroundColor: 'var(--bg-menu)',
97-
}),
98-
...styleOverrides,
99-
})
100-
10133
/**
10234
* Returns the redirection props for a url
10335
*/

src/Common/RJSF/widgets/Select.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React from 'react'
1817
import { WidgetProps } from '@rjsf/utils'
1918
import ReactSelect, { MenuListProps, components } from 'react-select'
2019
import { PLACEHOLDERS } from '../constants'
21-
import { getCommonSelectStyle } from '../utils'
2220

2321
import { ReactComponent as ArrowDown } from '../../../Assets/Icon/ic-chevron-down.svg'
2422
import { deepEqual } from '@Common/Helper'
25-
26-
const commonStyles = getCommonSelectStyle()
23+
import { commonSelectStyles } from '@Shared/Components'
2724

2825
const MenuList = ({ children, ...props }: MenuListProps) => (
2926
<components.MenuList {...props}>{Array.isArray(children) ? children.slice(0, 20) : children}</components.MenuList>
@@ -75,10 +72,10 @@ export const SelectWidget = (props: WidgetProps) => {
7572
placeholder={placeholder || PLACEHOLDERS.SELECT}
7673
isDisabled={disabled || readonly}
7774
styles={{
78-
...commonStyles,
75+
...commonSelectStyles,
7976
control: (base, state) => ({
80-
...commonStyles.control(base, state),
81-
height: '36px'
77+
...commonSelectStyles.control(base, state),
78+
height: '36px',
8279
}),
8380
}}
8481
components={{

src/Shared/Components/ReactSelect/utils.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
import { cloneElement } from 'react'
1818
import Tippy from '@tippyjs/react'
19-
import { components, MenuListProps, ValueContainerProps } from 'react-select'
19+
import { components, MenuListProps, StylesConfig, ValueContainerProps } from 'react-select'
2020
import { OptionType, Progressing, stopPropagation } from '../../../Common'
2121
import { ReactComponent as ICSearch } from '../../../Assets/Icon/ic-search.svg'
2222
import { ReactComponent as ICFilter } from '../../../Assets/Icon/ic-filter.svg'
2323
import { ReactComponent as ICFilterApplied } from '../../../Assets/Icon/ic-filter-applied.svg'
2424

25-
export const getCommonSelectStyle = (styleOverrides = {}) => ({
25+
export const getCommonSelectStyle = (styleOverrides = {}): StylesConfig => ({
2626
container: (base, state) => ({
2727
...base,
2828
...(state.isDisabled && {
@@ -128,6 +128,28 @@ export const getCommonSelectStyle = (styleOverrides = {}) => ({
128128
...base,
129129
backgroundColor: 'var(--bg-menu)',
130130
}),
131+
multiValue: (base) => ({
132+
...base,
133+
background: 'var(--bg-primary)',
134+
border: '1px solid var(--N200)',
135+
borderRadius: '4px',
136+
padding: '1px 5px',
137+
maxWidth: '250px',
138+
margin: 0,
139+
display: 'flex',
140+
alignItems: 'center',
141+
gap: '4px',
142+
}),
143+
multiValueLabel: (base) => ({
144+
...base,
145+
borderRadius: 0,
146+
color: 'var(--N900)',
147+
fontSize: '12px',
148+
fontWeight: 400,
149+
lineHeight: '20px',
150+
padding: 0,
151+
paddingLeft: 0,
152+
}),
131153
...styleOverrides,
132154
})
133155

0 commit comments

Comments
 (0)