Skip to content

Commit b1fa552

Browse files
committed
feat: add support for close icon
1 parent c777e95 commit b1fa552

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

src/Shared/Components/SelectPicker/SelectPicker.component.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import ReactSelect, { ControlProps, MenuProps, Props as ReactSelectProps } from 'react-select'
22
import { ReactElement, ReactNode, useCallback, useMemo } from 'react'
33
import { ReactComponent as ErrorIcon } from '@Icons/ic-warning.svg'
4-
import { ReactComponent as ICInfoFilledOverride } from '@Icons/ic-info-filled-override.svg'
4+
import { ReactComponent as ICInfoFilledOverride } from '@Icons/ic-info-filled.svg'
55
import { getCommonSelectStyle } from './utils'
66
import {
7+
SelectPickerClearIndicator,
78
SelectPickerControl,
89
SelectPickerDropdownIndicator,
910
SelectPickerLoadingIndicator,
@@ -99,6 +100,7 @@ const SelectPicker = ({
99100
Control: renderControl,
100101
Option: SelectPickerOption,
101102
Menu: renderMenu,
103+
ClearIndicator: SelectPickerClearIndicator,
102104
// TODO Eshank: need to export variants of ValueContainer: Icon, No Icon etc
103105
}}
104106
styles={selectStyles}

src/Shared/Components/SelectPicker/common.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
import { components, DropdownIndicatorProps, ControlProps, OptionProps, MenuProps } from 'react-select'
2-
import { ReactComponent as ICCaretDown } from '@Icons/ic-caret-down.svg'
1+
import {
2+
components,
3+
DropdownIndicatorProps,
4+
ControlProps,
5+
OptionProps,
6+
MenuProps,
7+
ClearIndicatorProps,
8+
} from 'react-select'
39
import { Progressing } from '@Common/Progressing'
10+
import { ReactComponent as ICChevronDown } from '@Icons/ic-chevron-down.svg'
11+
import { ReactComponent as ICClose } from '@Icons/ic-close.svg'
412
import { SelectPickerProps } from './SelectPicker.component'
513
import { SelectPickerOptionType } from './type'
614

@@ -9,11 +17,17 @@ export const SelectPickerDropdownIndicator = (props: DropdownIndicatorProps) =>
917

1018
return (
1119
<components.DropdownIndicator {...props}>
12-
<ICCaretDown className={`icon-dim-16 ${isDisabled ? 'fcn-3' : 'fcn-6'} dc__no-shrink`} />
20+
<ICChevronDown className={`icon-dim-16 ${isDisabled ? 'fcn-3' : 'fcn-6'} dc__no-shrink`} />
1321
</components.DropdownIndicator>
1422
)
1523
}
1624

25+
export const SelectPickerClearIndicator = (props: ClearIndicatorProps) => (
26+
<components.ClearIndicator {...props}>
27+
<ICClose className="icon-dim-16 fcn-6 dc__no-shrink" />
28+
</components.ClearIndicator>
29+
)
30+
1731
export const SelectPickerControl = ({ icon, ...props }: ControlProps & Pick<SelectPickerProps, 'icon'>) => {
1832
const { children } = props
1933

src/Shared/Components/SelectPicker/utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ export const getCommonSelectStyle = ({ hasError }: { hasError: boolean }) => ({
6161
transition: 'all .2s ease',
6262
transform: state.selectProps.menuIsOpen ? 'rotate(180deg)' : 'rotate(0deg)',
6363
}),
64+
clearIndicator: (base) => ({
65+
...base,
66+
padding: 0,
67+
}),
6468
valueContainer: (base) => ({
6569
...base,
6670
padding: '0',
@@ -112,4 +116,9 @@ export const getCommonSelectStyle = ({ hasError }: { hasError: boolean }) => ({
112116
textOverflow: 'ellipsis',
113117
whiteSpace: 'nowrap',
114118
}),
119+
indicatorsContainer: (base) => ({
120+
...base,
121+
gap: '4px',
122+
flexShrink: 0,
123+
}),
115124
})

0 commit comments

Comments
 (0)