Skip to content

Commit fdf2c98

Browse files
authored
Merge pull request #666 from devtron-labs/feat/select-picker-variants
feat: add compact & border less variant for select picker
2 parents 67be9e4 + ecebd18 commit fdf2c98

File tree

10 files changed

+263
-222
lines changed

10 files changed

+263
-222
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.10.4",
3+
"version": "1.10.5",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/ChartVersionAndTypeSelector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const ChartVersionAndTypeSelector = ({ setSelectedChartRefId }: ChartVersionAndT
8383
value={selectedChartType ?? chartTypeOptions[0]}
8484
options={chartTypeOptions}
8585
onChange={handleChartTypeChange}
86-
variant={SelectPickerVariantType.BORDER_LESS}
86+
variant={SelectPickerVariantType.COMPACT}
8787
/>
8888
</div>
8989
<div className="chart-version-options flex" data-testid="chart-version-options">
@@ -93,7 +93,7 @@ const ChartVersionAndTypeSelector = ({ setSelectedChartRefId }: ChartVersionAndT
9393
value={selectedChartVersion ?? chartVersionOptions[0]}
9494
options={chartVersionOptions}
9595
onChange={handleChartVersionChange}
96-
variant={SelectPickerVariantType.BORDER_LESS}
96+
variant={SelectPickerVariantType.COMPACT}
9797
/>
9898
</div>
9999
</div>

src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/DeploymentHistoryConfigDiffCompare.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export const DeploymentHistoryConfigDiffCompare = ({
147147
name: 'deployment-config-diff-deployment-selector',
148148
inputId: 'deployment-config-diff-deployment-selector',
149149
classNamePrefix: 'deployment-config-diff-deployment-selector',
150-
variant: SelectPickerVariantType.BORDER_LESS,
150+
variant: SelectPickerVariantType.COMPACT,
151151
options: pipelineDeploymentsOptions,
152152
placeholder: 'Select Deployment',
153153
value: getSelectPickerOptionByValue(pipelineDeploymentsOptions, compareWfrId, null),

src/Shared/Components/DynamicDataTable/DynamicDataTableRow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export const DynamicDataTableRow = <K extends string, CustomStateType = Record<s
169169
{...row.data[key].props}
170170
inputId={`data-table-${row.id}-${key}-cell`}
171171
classNamePrefix="dynamic-data-table__cell__select-picker"
172-
variant={SelectPickerVariantType.BORDER_LESS}
172+
variant={SelectPickerVariantType.COMPACT}
173173
value={getSelectPickerOptionByValue(
174174
row.data[key].props?.options,
175175
row.data[key].value,
@@ -191,7 +191,7 @@ export const DynamicDataTableRow = <K extends string, CustomStateType = Record<s
191191
isCreatable={isCreatable}
192192
isClearable
193193
{...props}
194-
variant={SelectPickerVariantType.BORDER_LESS}
194+
variant={SelectPickerVariantType.COMPACT}
195195
classNamePrefix="dynamic-data-table__cell__select-picker-text-area"
196196
inputId={`data-table-${row.id}-${key}-cell`}
197197
minHeight={20}

src/Shared/Components/GraphVisualizer/components/DropdownNode.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const DropdownNode = ({ id, data, isConnectable }: NodeProps<DropdownNode
3434
<SelectPicker<string | number, false>
3535
{...restData}
3636
classNamePrefix="graph-visualizer-dropdown-node"
37-
variant={SelectPickerVariantType.BORDER_LESS}
37+
variant={SelectPickerVariantType.COMPACT}
3838
menuPortalTarget={document.querySelector('.graph-visualizer')}
3939
menuSize={ComponentSizeType.xs}
4040
fullWidth

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,12 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
360360
e.preventDefault()
361361
}
362362

363-
if (e.key === 'Escape' && !selectRef.current.props.menuIsOpen) {
364-
selectRef.current.blur()
363+
if (e.key === 'Escape') {
364+
e.stopPropagation()
365+
366+
if (!selectRef.current.props.menuIsOpen) {
367+
selectRef.current.blur()
368+
}
365369
}
366370

367371
onKeyDown?.(e)

src/Shared/Components/SelectPicker/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,19 @@ export const SELECT_PICKER_FONT_SIZE_MAP: Record<SelectPickerProps['size'], CSSP
2222
[ComponentSizeType.small]: '12px',
2323
[ComponentSizeType.medium]: '13px',
2424
[ComponentSizeType.large]: '13px',
25+
[ComponentSizeType.xl]: '16px',
2526
}
2627

2728
export const SELECT_PICKER_ICON_SIZE_MAP: Record<SelectPickerProps['size'], Pick<CSSProperties, 'width' | 'height'>> = {
2829
[ComponentSizeType.small]: { width: '12px', height: '12px' },
2930
[ComponentSizeType.medium]: { width: '16px', height: '16px' },
3031
[ComponentSizeType.large]: { width: '16px', height: '16px' },
32+
[ComponentSizeType.xl]: { width: '16px', height: '16px' },
3133
}
3234

3335
export const SELECT_PICKER_CONTROL_SIZE_MAP: Record<SelectPickerProps['size'], CSSProperties['minHeight']> = {
3436
[ComponentSizeType.small]: 'auto',
3537
[ComponentSizeType.medium]: 'auto',
3638
[ComponentSizeType.large]: '36px',
39+
[ComponentSizeType.xl]: '36px',
3740
}

src/Shared/Components/SelectPicker/type.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ declare module 'react-select/base' {
127127
export enum SelectPickerVariantType {
128128
DEFAULT = 'default',
129129
BORDER_LESS = 'border-less',
130+
COMPACT = 'compact',
130131
}
131132

132133
export type SelectPickerProps<OptionValue = number | string, IsMulti extends boolean = false> = Pick<
@@ -200,7 +201,10 @@ export type SelectPickerProps<OptionValue = number | string, IsMulti extends boo
200201
*
201202
* @default 'ComponentSizeType.medium'
202203
*/
203-
size?: Extract<ComponentSizeType, ComponentSizeType.medium | ComponentSizeType.large | ComponentSizeType.small>
204+
size?: Extract<
205+
ComponentSizeType,
206+
ComponentSizeType.medium | ComponentSizeType.large | ComponentSizeType.small | ComponentSizeType.xl
207+
>
204208
/**
205209
* Content to be shown in a tippy when disabled
206210
*/

0 commit comments

Comments
 (0)