Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnCh committed Aug 6, 2024
1 parent de4a8b0 commit e037c5a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
21 changes: 16 additions & 5 deletions src/components/Chip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,24 @@ export function WithIcon() {
);
}

export function WithStartAdorment() {
export function WithCustomLabel() {
return (
<div css={Css.wPx(200).$}>
<Chip startAdornment={<span css={Css.smBd.$}>K</span>} text="Kitchen" />
<div css={Css.wPx(200).df.gap1.$}>
<Chip
text={
<span css={Css.sm.df.gap1.$}>
<span css={Css.smBd.$}>K</span>
Kitchen
</span>
}
/>
<Chip
startAdornment={<span css={Css.smBd.$}>A</span>}
text="A very long chip name that will eventually truncate"
text={
<span css={Css.sm.df.gap1.$}>
<span css={Css.smBd.$}>B</span>
Bedroom
</span>
}
/>
</div>
);
Expand Down
6 changes: 2 additions & 4 deletions src/components/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ export const ChipTypes: Record<ChipType, ChipType> = {
};

export interface ChipProps<X> {
text: string;
text: ReactNode;
title?: ReactNode;
startAdornment?: ReactNode;
xss?: X;
type?: ChipType;
compact?: boolean;
Expand All @@ -35,7 +34,7 @@ export function Chip<X extends Only<Xss<Margin | "color" | "backgroundColor">, X
...props
}: ChipProps<X>) {
const { fieldProps } = usePresentationContext();
const { text, title, xss = {}, compact = fieldProps?.compact, icon, startAdornment } = props;
const { text, title, xss = {}, compact = fieldProps?.compact, icon } = props;
const tid = useTestIds(props, "chip");

return maybeTooltip({
Expand All @@ -51,7 +50,6 @@ export function Chip<X extends Only<Xss<Margin | "color" | "backgroundColor">, X
{...tid}
>
{icon && <Icon icon={icon} inc={2} xss={Css.fs0.$} />}
{startAdornment}
<span css={Css.lineClamp1.wbba.$}>{text}</span>
</span>
),
Expand Down

0 comments on commit e037c5a

Please sign in to comment.