Skip to content

Commit 7828eb4

Browse files
author
Kubit
committed
Improve pillSelector and Pill styles and features
1 parent 15c3bc2 commit 7828eb4

File tree

9 files changed

+18
-14
lines changed

9 files changed

+18
-14
lines changed

src/components/pillSelector/pillSelectorStandAlone.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ const PillSelectorStandAloneComponent = (
3333

3434
const isPillSelected = props.pillSelected?.length !== 0;
3535

36-
React.useImperativeHandle(ref, () => {
37-
return listEl.current as HTMLDivElement;
38-
}, []);
36+
React.useImperativeHandle(
37+
ref,
38+
() => {
39+
return listEl.current as HTMLDivElement;
40+
},
41+
[]
42+
);
3943

4044
return (
4145
<PillSelectorWrapper

src/components/pillSelectorV2/__tests__/pillSelector.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const mockProps: IPillSelectorUnControlled = {
2020
size: PillSelectorSizeTypeV2.LARGE,
2121
pills: [
2222
{ label: { content: 'Pill 1' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 1' },
23-
{ label: { content: 'Pill 2 ' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 2' },
23+
{ label: { content: 'Pill 2' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 2' },
2424
{ label: { content: 'Pill 3' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 3' },
2525
{ label: { content: 'Pill 4' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 4' },
2626
],
@@ -140,7 +140,7 @@ const mockPropsControlled: IPillSelectorControlled = {
140140
size: PillSelectorSizeTypeV2.LARGE,
141141
pills: [
142142
{ label: { content: 'Pill 1' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 1' },
143-
{ label: { content: 'Pill 2 ' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 2' },
143+
{ label: { content: 'Pill 2' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 2' },
144144
{ label: { content: 'Pill 3' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 3' },
145145
{ label: { content: 'Pill 4' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 4' },
146146
],

src/components/pillSelectorV2/pillSelectorStandAlone.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const PillSelectorStandAloneComponent = (
1010
ref: React.ForwardedRef<HTMLDivElement> | undefined | null
1111
): JSX.Element => {
1212
return (
13-
<RootContainerStyled ref={ref} styles={props.styles}>
13+
<RootContainerStyled ref={ref} data-testid={dataTestId} styles={props.styles}>
1414
{props.pills?.map((pill, index) => {
1515
const selected =
1616
props.type === PillSelectorType.SELECTOR_MULTIPLE

src/components/pillSelectorV2/stories/argtypes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const argtypes = (
1111
return {
1212
variant: {
1313
description: 'Variant',
14-
type: { name: 'string', required: true },
14+
type: { name: 'string' },
1515
control: { type: 'select' },
1616
options: Object.keys(variantsObject[themeSelected].PillSelectorVariantTypeV2 || {}),
1717
table: {
@@ -59,7 +59,7 @@ export const argtypes = (
5959
},
6060
},
6161
selectedIcon: {
62-
description: 'Icon to show when the pill is selected',
62+
description: 'Icon to show when a pill is selected',
6363
type: { name: 'object' },
6464
table: {
6565
type: {
@@ -119,7 +119,7 @@ export const argtypes = (
119119
type: {
120120
summary: 'string',
121121
},
122-
defaultValue: { summary: 'segmentedControl' },
122+
defaultValue: { summary: 'pillSelector' },
123123
category: CATEGORY_CONTROL.TESTING,
124124
},
125125
},

src/components/pillSelectorV2/stories/controlled/argtypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const argtypes = (
1111
return {
1212
variant: {
1313
description: 'Variant',
14-
type: { name: 'string', required: true },
14+
type: { name: 'string' },
1515
control: { type: 'select' },
1616
options: Object.keys(variantsObject[themeSelected].PillSelectorVariantTypeV2 || {}),
1717
table: {

src/components/pillSelectorV2/stories/controlled/pillSelector.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const commonPillSelectorProps: IPillSelectorControlled = {
3030
)[0] as string,
3131
pills: [
3232
{ label: { content: 'Pill 1' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 1' },
33-
{ label: { content: 'Pill 2 ' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 2' },
33+
{ label: { content: 'Pill 2' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 2' },
3434
{ label: { content: 'Pill 3' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 3' },
3535
{ label: { content: 'Pill 4' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 4' },
3636
],

src/components/pillSelectorV2/stories/pillSelector.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const commonPillSelectorProps: IPillSelectorUnControlled = {
3131
)[0] as string,
3232
pills: [
3333
{ label: { content: 'Pill 1' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 1' },
34-
{ label: { content: 'Pill 2 ' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 2' },
34+
{ label: { content: 'Pill 2' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 2' },
3535
{ label: { content: 'Pill 3' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 3' },
3636
{ label: { content: 'Pill 4' }, icon: { icon: ICONS.ICON_PLACEHOLDER }, value: 'value 4' },
3737
],

src/components/pillV2/pill.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getPillState } from './utils';
99

1010
const PillComponent = (
1111
{ variant, size, ctv, selected = false, disabled = false, ...props }: IPill,
12-
ref: React.ForwardedRef<HTMLButtonElement>
12+
ref: React.ForwardedRef<HTMLDivElement>
1313
) => {
1414
const variantStyles = useStylesV2<PillVariantPropsStylesType>({
1515
styleName: STYLES_NAME.PILL_V2,

src/components/pillV2/pillStandAlone.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { IPillStandAlone, PillType } from './types';
1818

1919
const PillStandAloneComponent = (
2020
{ dataTestId = 'pill', type = PillType.BUTTON, ...props }: IPillStandAlone,
21-
ref: React.ForwardedRef<HTMLButtonElement> | undefined | null
21+
ref: React.ForwardedRef<HTMLDivElement> | undefined | null
2222
): JSX.Element => {
2323
const id = useId('pill');
2424
const pillContentId = `${id}-content`;

0 commit comments

Comments
 (0)