Skip to content

Commit 2bc148d

Browse files
committed
feat: add support for size
1 parent 6633295 commit 2bc148d

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import ReactSelect, { ControlProps, MenuProps } from 'react-select'
22
import { useCallback, useMemo } from 'react'
33
import { ReactComponent as ErrorIcon } from '@Icons/ic-warning.svg'
44
import { ReactComponent as ICInfoFilledOverride } from '@Icons/ic-info-filled-override.svg'
5+
import { ComponentSizeType } from '@Shared/constants'
56
import { getCommonSelectStyle } from './utils'
67
import {
78
SelectPickerClearIndicator,
@@ -22,16 +23,18 @@ const SelectPicker = ({
2223
placeholder = 'Select a option',
2324
label,
2425
showSelectedOptionIcon = true,
26+
size = ComponentSizeType.medium,
2527
...props
2628
}: SelectPickerProps) => {
2729
const { inputId, required } = props
2830

2931
const selectStyles = useMemo(
3032
() =>
3133
getCommonSelectStyle({
32-
hasError: !!error,
34+
error,
35+
size,
3336
}),
34-
[error],
37+
[error, size],
3538
)
3639

3740
const renderControl = useCallback(

src/Shared/Components/SelectPicker/type.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { OptionType } from '@Common/Types'
2+
import { ComponentSizeType } from '@Shared/constants'
23
import { ReactElement, ReactNode } from 'react'
34
import { Props as ReactSelectProps } from 'react-select'
45

@@ -41,4 +42,10 @@ export interface SelectPickerProps
4142
* @default 'true'
4243
*/
4344
showSelectedOptionIcon?: boolean
45+
/**
46+
* Height of the dropdown
47+
*
48+
* @default 'ComponentSizeType.medium'
49+
*/
50+
size?: Extract<ComponentSizeType, ComponentSizeType.medium | ComponentSizeType.large>
4451
}

src/Shared/Components/SelectPicker/utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
export const getCommonSelectStyle = ({ hasError }: { hasError: boolean }) => ({
1+
import { ComponentSizeType } from '@Shared/constants'
2+
import { SelectPickerProps } from './type'
3+
4+
export const getCommonSelectStyle = ({ error, size }: Pick<SelectPickerProps, 'error' | 'size'>) => ({
25
container: (base, state) => ({
36
...base,
47
...(state.isDisabled && {
@@ -22,11 +25,10 @@ export const getCommonSelectStyle = ({ hasError }: { hasError: boolean }) => ({
2225
}),
2326
control: (base, state) => ({
2427
...base,
25-
// Add support for configurable: 36px, 28px
26-
minHeight: 'auto',
28+
minHeight: size === ComponentSizeType.medium ? 'auto' : '36px',
2729
boxShadow: 'none',
2830
backgroundColor: 'var(--N50)',
29-
border: `1px solid ${hasError ? 'var(--R500)' : 'var(--N200)'}`,
31+
border: `1px solid ${error ? 'var(--R500)' : 'var(--N200)'}`,
3032
cursor: state.isDisabled ? 'not-allowed' : 'pointer',
3133
padding: '5px 8px',
3234
gap: '8px',

src/Shared/constants.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,9 @@ export enum K8sResourcePayloadAppType {
410410
HELM_APP = 1,
411411
EXTERNAL_ARGO_APP = 2,
412412
}
413+
414+
export enum ComponentSizeType {
415+
small = 'small',
416+
medium = 'medium',
417+
large = 'large',
418+
}

0 commit comments

Comments
 (0)