Skip to content

Commit 8a3a557

Browse files
authored
Merge pull request #415 from mashmatrix/fix-csf3-stories
Modifiy stories using CSF3 features
2 parents b10a467 + b4b5801 commit 8a3a557

33 files changed

+4168
-3243
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
'plugins': [
1111
'@typescript-eslint',
1212
'jsx-a11y',
13+
'prettier',
1314
],
1415
'parserOptions': {
1516
'sourceType': 'module',
@@ -37,5 +38,6 @@ module.exports = {
3738
'react/display-name': 1,
3839
'react/no-deprecated': 1,
3940
// tmp disabled - end
41+
'prettier/prettier': 2,
4042
}
4143
};

.storybook/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
addons: [
66
'@storybook/addon-docs',
77
'@storybook/addon-actions',
8-
'@storybook/addon-knobs',
8+
'@storybook/addon-controls',
99
'storycap',
1010
],
1111
};

src/scripts/MediaObject.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type MediaObjectProps = {
55
figureLeft?: ReactNode;
66
figureRight?: ReactNode;
77
figureCenter?: ReactNode;
8+
children?: ReactNode;
89
};
910

1011
export class MediaObject extends Component<MediaObjectProps, {}> {

stories/Badge.stories.tsx

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,58 @@
1-
import React from 'react';
2-
import { action } from '@storybook/addon-actions';
31
import { Badge } from '../src/scripts';
4-
export default {
2+
import { ComponentMeta, ComponentStoryObj } from '@storybook/react';
3+
4+
/**
5+
*
6+
*/
7+
const meta: ComponentMeta<typeof Badge> = {
58
title: 'Badge',
9+
component: Badge,
10+
argTypes: {
11+
onClick: { action: 'click' },
12+
},
613
};
7-
export const Default = {
8-
render: () => <Badge onClick={action('click')}>Badge Label</Badge>,
14+
export default meta;
15+
16+
/**
17+
*
18+
*/
19+
export const Default: ComponentStoryObj<typeof Badge> = {
20+
args: {
21+
children: 'Badge Label',
22+
},
923
parameters: {
10-
info: 'Default badge',
24+
docs: {
25+
storyDescription: 'Default badge',
26+
},
1127
},
1228
};
13-
export const Shade = {
14-
render: () => (
15-
<Badge type='shade' onClick={action('click')}>
16-
Badge Label
17-
</Badge>
18-
),
29+
30+
/**
31+
*
32+
*/
33+
export const Shade: ComponentStoryObj<typeof Badge> = {
34+
args: {
35+
type: 'shade',
36+
children: 'Badge Label',
37+
},
1938
parameters: {
20-
info: 'Badge with type: shade',
39+
docs: {
40+
storyDescription: 'Badge with type: shade',
41+
},
2142
},
2243
};
23-
export const Inverse = {
24-
render: () => (
25-
<Badge type='inverse' onClick={action('click')}>
26-
Badge Label
27-
</Badge>
28-
),
44+
45+
/**
46+
*
47+
*/
48+
export const Inverse: ComponentStoryObj<typeof Badge> = {
49+
args: {
50+
type: 'inverse',
51+
children: 'Badge Label',
52+
},
2953
parameters: {
30-
info: 'Badge with type: inverse',
54+
docs: {
55+
storyDescription: 'Badge with type: inverse',
56+
},
3157
},
3258
};

stories/BreadCrumbs.stories.tsx

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,49 @@
1-
import React from 'react';
2-
import { action } from '@storybook/addon-actions';
1+
import React, { ComponentProps } from 'react';
32
import { BreadCrumbs, Crumb } from '../src/scripts';
4-
export default {
3+
import { Meta, StoryObj } from '@storybook/react';
4+
5+
type StoryProps = ComponentProps<typeof BreadCrumbs> & {
6+
crumb1: ComponentProps<typeof Crumb>;
7+
crumb1_onClick: ComponentProps<typeof Crumb>['onClick'];
8+
} & {
9+
crumb2: ComponentProps<typeof Crumb>;
10+
crumb2_onClick: ComponentProps<typeof Crumb>['onClick'];
11+
};
12+
13+
/**
14+
*
15+
*/
16+
const meta: Meta<StoryProps> = {
517
title: 'BreadCrumbs',
18+
component: BreadCrumbs,
19+
argTypes: {
20+
crumb1_onClick: { action: 'crumb1_click' },
21+
crumb2_onClick: { action: 'crumb2_click' },
22+
},
623
};
7-
export const Default = {
8-
render: () => (
9-
<BreadCrumbs>
10-
<Crumb onClick={action('crumb1#click')}>Parent Entity</Crumb>
11-
<Crumb onClick={action('crumb2#click')}>Parent Record Name</Crumb>
24+
export default meta;
25+
26+
/**
27+
*
28+
*/
29+
export const Default: StoryObj<StoryProps> = {
30+
render: ({ crumb1, crumb2, crumb1_onClick, crumb2_onClick, ...args }) => (
31+
<BreadCrumbs {...args}>
32+
<Crumb onClick={crumb1_onClick} {...crumb1} />
33+
<Crumb onClick={crumb2_onClick} {...crumb2} />
1234
</BreadCrumbs>
1335
),
36+
args: {
37+
crumb1: {
38+
children: 'Parent Entity',
39+
},
40+
crumb2: {
41+
children: 'Parent Record Name',
42+
},
43+
},
1444
parameters: {
15-
info: 'Default BreadCrumbs',
45+
docs: {
46+
storyDescription: 'Default BreadCrumbs',
47+
},
1648
},
1749
};

0 commit comments

Comments
 (0)