Skip to content

Commit cfd1e0c

Browse files
author
Lucas
authored
Merge pull request #19 from input-output-hk/chore/updates-from-lace-fork
feat: add toggle button group small variant feat: add color schema decorator layout prop feat: add card image variant feat: add height prop to divider
2 parents bc3bb57 + b6aac9a commit cfd1e0c

16 files changed

+138
-39
lines changed

src/design-system/cards/base-card.css.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export const card = recipe({
2727
borderStyle: 'solid',
2828
borderWidth: vars.spacing.$2,
2929
},
30+
[Scheme.Img]: {
31+
borderColor: vars.colors.$card_img_borderColor,
32+
backgroundColor: vars.colors.$card_img_bgColor,
33+
borderRadius: vars.radius.$large,
34+
},
3035
},
3136
},
3237
});

src/design-system/cards/cards.stories.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export const Overview = (): JSX.Element => {
4141
Component: Card.Outlined,
4242
variant: Scheme.Outlined,
4343
},
44+
{
45+
Component: Card.Img,
46+
variant: Scheme.Img,
47+
},
4448
];
4549

4650
const renderTable = (showHeader = false): JSX.Element => (
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createCardVariantComponent } from './create-card-variant-component.util';
2+
import { Scheme } from './types';
3+
4+
import type { VariantCardProps } from './create-card-variant-component.util';
5+
6+
export type ElevatedProps = VariantCardProps;
7+
8+
export const Img = createCardVariantComponent<ElevatedProps>(Scheme.Img);

src/design-system/cards/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { Elevated } from './elevated.component';
22
export { Greyed } from './greyed.component';
33
export { Outlined } from './outlined.component';
4+
export { Img } from './img.component';

src/design-system/cards/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export enum Scheme {
22
Elevated = 'Elevated',
33
Greyed = 'Greyed',
44
Outlined = 'Outlined',
5+
Img = 'Img',
56
}

src/design-system/decorators/color-schema/color-schema.css.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@ export const storyContainer = style([
1414
export const root = style({
1515
minHeight: '100%',
1616
height: '100%',
17-
display: 'flex',
18-
flexDirection: 'row',
1917
});

src/design-system/decorators/color-schema/color-schema.decorator.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@ import type { DecoratorFunction } from '@storybook/csf/dist/story';
44
import type { ReactFramework } from '@storybook/react';
55

66
import { ThemeColorScheme, LocalThemeProvider } from '../../../design-tokens';
7+
import { Flex } from '../../flex';
78

89
import * as styles from './color-schema.css';
910

10-
export const colorSchemaDecorator: DecoratorFunction<
11-
ReactFramework
12-
> = Story => (
13-
<div className={styles.root}>
11+
export const colorSchemaDecorator: DecoratorFunction<ReactFramework> = (
12+
Story,
13+
{
14+
parameters: {
15+
decorators: { layout = 'horizontal' },
16+
},
17+
},
18+
) => (
19+
<Flex
20+
className={styles.root}
21+
flexDirection={layout === 'horizontal' ? 'row' : 'column'}
22+
>
1423
<LocalThemeProvider
1524
colorScheme={ThemeColorScheme.Light}
1625
className={styles.storyContainer}
@@ -23,5 +32,5 @@ export const colorSchemaDecorator: DecoratorFunction<
2332
>
2433
<Story />
2534
</LocalThemeProvider>
26-
</div>
35+
</Flex>
2736
);

src/design-system/divider/divider.component.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import type { BoxProps } from '../box';
99

1010
export type Props = PropsWithChildren<Readonly<Omit<BoxProps, 'className'>>>;
1111

12-
export const Divider = (props: Readonly<BoxProps>): JSX.Element => (
13-
<Box {...props} h="$1" className={cx.divider} />
12+
export const Divider = ({
13+
h = '$1',
14+
...props
15+
}: Readonly<BoxProps>): JSX.Element => (
16+
<Box {...props} h={h} className={cx.divider} />
1417
);

src/design-system/toggle-button-group/toggle-button-group-item.component.tsx

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import cn from 'classnames';
66
import { Text } from '../text';
77

88
import * as cx from './toggle-button-group-item.css';
9+
import { useToggleButtonGroupContext } from './toggle-button-group-root.component';
910

1011
import type { ToggleGroupItemProps } from '@radix-ui/react-toggle-group';
1112

@@ -20,20 +21,27 @@ export const Item = forwardRef<HTMLButtonElement, ToggleButtonGroupItemProps>(
2021
(
2122
{ icon: IconComponent, children, ...props },
2223
forwardReference,
23-
): JSX.Element => (
24-
<ToggleGroup.Item
25-
className={cn(cx.root, cx.rootHandle)}
26-
ref={forwardReference}
27-
{...props}
28-
>
29-
{IconComponent && <IconComponent className={cx.icon} />}
30-
{Boolean(children) && (
31-
<Text.Button weight="$semibold" className={cx.label}>
32-
{children}
33-
</Text.Button>
34-
)}
35-
</ToggleGroup.Item>
36-
),
24+
): JSX.Element => {
25+
const variant = useToggleButtonGroupContext();
26+
27+
return (
28+
<ToggleGroup.Item
29+
className={cn(cx.root, cx.rootHandle, {
30+
[cx.smallVariant]: variant === 'small',
31+
[cx.commonVariant]: variant !== 'small',
32+
})}
33+
ref={forwardReference}
34+
{...props}
35+
>
36+
{IconComponent && <IconComponent className={cx.icon} />}
37+
{Boolean(children) && (
38+
<Text.Button weight="$semibold" className={cx.label}>
39+
{children}
40+
</Text.Button>
41+
)}
42+
</ToggleGroup.Item>
43+
);
44+
},
3745
);
3846

3947
Item.displayName = 'Item';

src/design-system/toggle-button-group/toggle-button-group-item.css.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export const root = style([
99
padding: '$8',
1010
color: '$toggle_button_group_item_label_color',
1111
backgroundColor: '$toggle_button_group_item_bgColor',
12-
borderRadius: '$small',
1312
gap: '$6',
1413
}),
1514
{
@@ -71,3 +70,11 @@ export const icon = sx({
7170
width: '$24',
7271
height: '$24',
7372
});
73+
74+
export const commonVariant = sx({
75+
borderRadius: '$small',
76+
});
77+
78+
export const smallVariant = sx({
79+
borderRadius: '$tiny',
80+
});

0 commit comments

Comments
 (0)