Skip to content

Commit 0d6d41e

Browse files
authored
feat: svg primitive story (#1029)
1 parent 5b70936 commit 0d6d41e

File tree

8 files changed

+60
-43
lines changed

8 files changed

+60
-43
lines changed

frontend/.storybook/preview.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
import Sprite from '@/components/icons/Sprite';
2+
13
export const parameters = {
2-
actions: { argTypesRegex: "^on[A-Z].*" },
4+
actions: { argTypesRegex: '^on[A-Z].*' },
35
controls: {
46
matchers: {
57
color: /(background|color)$/i,
68
date: /Date$/,
79
},
810
},
9-
}
11+
};
12+
13+
export const decorators = [
14+
(Story) => (
15+
<>
16+
<Sprite />
17+
<Story />
18+
</>
19+
),
20+
];

frontend/src/components/Primitives/Shape.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

frontend/src/stories/AlertDialog.stories.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
AlertDialogAction,
99
AlertDialogCancel,
1010
} from '@/components/Primitives/AlertDialog';
11-
import Sprite from '@/components/icons/Sprite';
1211
import Flex from '@/components/Primitives/Flex';
1312
import Button from '@/components/Primitives/Button';
1413

@@ -21,11 +20,6 @@ export default {
2120
exclude: ['ref', 'as', 'css'],
2221
sort: 'requiredFirst',
2322
},
24-
docs: {
25-
description: {
26-
component: '', // Change main component description in docs page
27-
},
28-
},
2923
},
3024
args: {
3125
title: 'Alert Dialog Title',
@@ -36,7 +30,6 @@ export default {
3630

3731
const Template: ComponentStory<typeof AlertDialog> = ({ children, ...args }) => (
3832
<AlertDialog>
39-
<Sprite />
4033
{/* Button to Open the Dialog */}
4134
<AlertDialogTrigger asChild>
4235
<Button>Open Alert Dialog</Button>

frontend/src/stories/Button.stories.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22
import { ComponentStory } from '@storybook/react';
33

44
import Button from '@/components/Primitives/Button';
5-
import Sprite from '@/components/icons/Sprite';
65
import Icon from '@/components/icons/Icon';
76
import Flex from '@/components/Primitives/Flex';
87
import Text from '@/components/Primitives/Text';
@@ -44,11 +43,6 @@ export default {
4443
exclude: ['ref', 'as', 'css'],
4544
sort: 'requiredFirst',
4645
},
47-
docs: {
48-
description: {
49-
component: '', // Change main component description in docs page
50-
},
51-
},
5246
},
5347
args: {
5448
children: 'Lorem',
@@ -127,7 +121,6 @@ export const Variants: ComponentStory<typeof Button> = ({ children, disabled })
127121

128122
export const IconButton: ComponentStory<typeof Button> = ({ children, disabled }) => (
129123
<Flex justify="evenly" wrap="wrap">
130-
<Sprite />
131124
{VARIANT_OPTIONS.map((variant) => (
132125
<Flex direction="column" justify="center" align="center" gap={20} key={variant}>
133126
<Text heading="5">Variant {variant}</Text>
@@ -144,7 +137,6 @@ export const IconButton: ComponentStory<typeof Button> = ({ children, disabled }
144137

145138
export const Icons: ComponentStory<typeof Button> = ({ disabled }) => (
146139
<Flex justify="evenly" wrap="wrap">
147-
<Sprite />
148140
{SIZE_OPTIONS.map((size) => (
149141
<Flex direction="column" justify="center" align="center" gap={20} key={size}>
150142
<Text heading="5">Size {size}</Text>

frontend/src/stories/Popover.stories.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
} from '@/components/Primitives/Popover';
1111
import Icon from '@/components/icons/Icon';
1212
import Text from '@/components/Primitives/Text';
13-
import Sprite from '@/components/icons/Sprite';
1413
import { PopoverVariantType, PopoverSizeType } from './types/PrimitiveTypes';
1514

1615
const VARIANT_OPTIONS: PopoverVariantType[] = ['dark', 'light'];
@@ -71,7 +70,6 @@ export default {
7170

7271
const Template: ComponentStory<typeof Popover> = ({ variant, size, disabled, active }: any) => (
7372
<>
74-
<Sprite />
7573
<Popover>
7674
<PopoverTrigger variant={variant} size={size} disabled={disabled}>
7775
<Icon name="menu-dots" />

frontend/src/stories/Select.stories.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
SelectIcon,
99
SelectContent,
1010
} from '@/components/Primitives/Select';
11-
import Sprite from '@/components/icons/Sprite';
1211
import Flex from '@/components/Primitives/Flex';
1312
import Text from '@/components/Primitives/Text';
1413
import Icon from '@/components/icons/Icon';
@@ -57,7 +56,6 @@ export default {
5756

5857
const Template: ComponentStory<typeof Select> = ({ disabled, hasError }) => (
5958
<Flex>
60-
<Sprite />
6159
<Select disabled={disabled} hasError={hasError} css={{ width: '$300' }}>
6260
<SelectTrigger css={{ padding: '$16' }}>
6361
<Flex direction="column">
@@ -80,7 +78,6 @@ export const WithLabel: ComponentStory<typeof Select> = ({ disabled, hasError })
8078

8179
return (
8280
<Flex>
83-
<Sprite />
8481
<Select
8582
disabled={disabled}
8683
hasError={hasError}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React from 'react';
2+
import { ComponentStory } from '@storybook/react';
3+
4+
import Svg from '@/components/Primitives/Svg';
5+
import Flex from '@/components/Primitives/Flex';
6+
import { SvgSizeType } from './types/PrimitiveTypes';
7+
8+
const SIZE_OPTIONS: SvgSizeType[] = [12, 16, 18, 20, 24, 32];
9+
10+
export default {
11+
title: 'Primitives/Svg',
12+
component: Svg,
13+
parameters: {
14+
controls: {
15+
expanded: true,
16+
exclude: ['ref', 'as', 'css'],
17+
sort: 'requiredFirst',
18+
},
19+
},
20+
args: {
21+
size: 32,
22+
},
23+
argTypes: {
24+
size: {
25+
options: SIZE_OPTIONS,
26+
control: { type: 'select' },
27+
description: 'The component size.',
28+
table: {
29+
type: { summary: SIZE_OPTIONS.join('|') },
30+
},
31+
},
32+
},
33+
};
34+
35+
const Template: ComponentStory<typeof Svg> = ({ size, ...args }) => (
36+
<Flex>
37+
<Svg size={size} {...args}>
38+
<use href="#user" />
39+
</Svg>
40+
</Flex>
41+
);
42+
43+
export const Default = Template.bind({});
44+
Default.storyName = 'Basic Usage';

frontend/src/stories/types/PrimitiveTypes.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ export type RadioGroupFontWeightType = 'regular' | 'medium' | 'bold';
4747
// Primitive/Separator
4848
export type SeparatorOrientationType = 'horizontal' | 'vertical';
4949
export type SeparatorSizeType = 'sm' | 'md' | 'lg' | 'full';
50+
51+
// Primitive/Svg
52+
export type SvgSizeType = 12 | 16 | 18 | 20 | 24 | 32;

0 commit comments

Comments
 (0)