Skip to content

Commit bf07e4e

Browse files
author
Hector Arce De Las Heras
committed
Enhance Pill component with styling, layout, and type improvements
This commit introduces styling and layout improvements to the Pill component, along with enhancements to its types. A new styled component, `IconContainerStyled`, has been introduced to handle the styles of the decorative icon container. This component uses the `IPillStyled` interface for its props and is utilized within the `PillStandAloneComponent` to wrap the `ElementOrIcon` component when a decorative icon is present. The `PillStateStylesType` interface has been enhanced with a new type, `decorativeIconContainer`, which handles the styles for the decorative icon container in the Pill component. These enhancements improve the styling and layout of the Pill component, making it more flexible and customizable.
1 parent 5e997a7 commit bf07e4e

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/components/pill/pill.styled.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ export const PillLabelStyled = styled.label<IPillStyled>`
2323
align-items: center;
2424
${props => getTypographyStyles(props.styles?.label)}
2525
`;
26+
27+
export const IconContainerStyled = styled.div<IPillStyled>`
28+
${props => getStyles(props.styles?.decorativeIconContainer)}
29+
`;

src/components/pill/pillStandAlone.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { InputTypeType } from '@/components/input';
55
import { useId } from '@/hooks';
66
import { pickAriaProps } from '@/utils/aria/aria';
77

8-
import { PillInputStyled, PillLabelStyled, PillStyled } from './pill.styled';
8+
import { IconContainerStyled, PillInputStyled, PillLabelStyled, PillStyled } from './pill.styled';
99
import { IPillStandAlone } from './types';
1010
import { getPillState } from './utils';
1111

@@ -60,13 +60,15 @@ const PillStandAloneComponent = (
6060
onFocus={onFocus}
6161
/>
6262
{decorativeIcon && (
63-
<ElementOrIcon
64-
color={stateStyles?.decorativeIcon?.color}
65-
dataTestId={dataTestId + 'DecorativeIcon'}
66-
height={stateStyles?.decorativeIcon?.height}
67-
width={stateStyles?.decorativeIcon?.width}
68-
{...decorativeIcon}
69-
/>
63+
<IconContainerStyled styles={stateStyles}>
64+
<ElementOrIcon
65+
color={stateStyles?.decorativeIcon?.color}
66+
dataTestId={dataTestId + 'DecorativeIcon'}
67+
height={stateStyles?.decorativeIcon?.height}
68+
width={stateStyles?.decorativeIcon?.width}
69+
{...decorativeIcon}
70+
/>
71+
</IconContainerStyled>
7072
)}
7173
<PillLabelStyled htmlFor={id} styles={stateStyles}>
7274
{children}

src/components/pill/types/pillTheme.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type PillStateStylesType = {
1111
box_shadow?: string;
1212
};
1313
input?: CommonStyleType;
14+
decorativeIconContainer?: CommonStyleType;
1415
decorativeIcon?: IconTypes;
1516
selectedIcon?: IconTypes;
1617
label?: TypographyTypes;

0 commit comments

Comments
 (0)