Skip to content

Commit

Permalink
feat: add key-value for multiline
Browse files Browse the repository at this point in the history
  • Loading branch information
niktverd committed Oct 1, 2024
1 parent bbf7e2a commit b42f46e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/components/Label/Label.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ $transition-timing-function: ease-in-out;
}

&_xs.g-label_multiline {
--_--addon-padding-on-multiline: 5px;
--_--label-padding-on-multiline: 2px;
--_--addon-padding-on-multiline: 4px;
--_--label-padding-on-multiline: 1px;
}

&_s {
Expand Down
15 changes: 10 additions & 5 deletions src/components/Label/__stories__/Label.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ export const LinkWrapper: Story = {
},
};

export const ShowcaseStory: Story = {
render: () => <LabelShowcase />,
name: 'Showcase',
};

export const Multiline: Story = {
render: (args) => (
<div style={{width: 75}}>
Expand All @@ -171,3 +166,13 @@ export const Multiline: Story = {
multiline: true,
},
};

export const ShowcaseStory: Story = {
render: () => <LabelShowcase />,
name: 'Showcase',
};

export const MultilineShowcaseStory: Story = {
render: () => <LabelShowcase multiline />,
name: 'Showcase (multiline)',
};
1 change: 1 addition & 0 deletions src/components/Label/__stories__/LabelShowcase.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.grid {
display: grid;
gap: 30px;
width: min-content;
}

.header {
Expand Down
38 changes: 26 additions & 12 deletions src/components/Label/__stories__/LabelShowcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,21 @@ const icons = (id: 'TickIcon' | 'GearIcon' | '-', size: 'xs' | 's' | 'm' = 'xs')
}[id];
};

export function LabelShowcase(args: LabelProps) {
const themes = [
'normal',
'info',
'success',
'warning',
'danger',
'utility',
'unknown',
'clear',
] as const;
type LabelShowcaseProps = LabelProps & {multiline?: boolean};

export function LabelShowcase({multiline, ...args}: LabelShowcaseProps) {
const themes = multiline
? (['normal'] as const)
: ([
'normal',
'info',
'success',
'warning',
'danger',
'utility',
'unknown',
'clear',
] as const);
const sizes = ['xs', 's', 'm'] as const;

const getLabel = ({...props}: WithKey<LabelProps>) => <Label {...props} />;
Expand Down Expand Up @@ -79,6 +83,8 @@ export function LabelShowcase(args: LabelProps) {
},
{children: 'Key', value: 'Value', type: 'close', closeButtonLabel: 'Close'},
{icon: icons('TickIcon', props.size)},
];
const multilineCases: LabelProps[] = [
{
children: 'Multiline ',
type: 'default',
Expand Down Expand Up @@ -151,8 +157,16 @@ export function LabelShowcase(args: LabelProps) {
closeButtonLabel: 'Close',
multiline: true,
},
{
children: 'Multiline key-value label: key',
value: 'Multiline key-value label: value',
icon: icons('TickIcon', props.size),
type: 'close',
closeButtonLabel: 'Close',
multiline: true,
},
];
return cases.map((label, i) => (
return (multiline ? multilineCases : cases).map((label, i) => (
<div style={{width: 'auto'}} key={i}>
{getLabel({key: i, ...props, ...label})}
</div>
Expand Down

0 comments on commit b42f46e

Please sign in to comment.