Skip to content

Commit ac899a0

Browse files
solimantdannify
andauthored
CSFy plop (#2160)
Co-authored-by: Danni <[email protected]>
1 parent ab3c350 commit ac899a0

File tree

2 files changed

+34
-26
lines changed

2 files changed

+34
-26
lines changed

plop-templates/@react-spectrum/chromatic/Component.chromatic.tsx.hbs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,28 @@
1111
*/
1212

1313
import { {{~componentName~}} } from '../';
14+
import {Meta, Story} from '@storybook/react';
1415
import React from 'react';
1516
{{#if (includes scopes "@react-types")}}
1617
import {Spectrum{{componentName}}Props} from '@react-types/{{packageName}}';
1718
{{/if}}
18-
import {storiesOf} from '@storybook/react';
19-
2019
{{#unless (includes scopes "@react-types")}}
20+
2121
interface Spectrum{{componentName}}Props {
2222

2323
}
2424
{{/unless}}
2525

26-
storiesOf('{{componentName}}', module)
27-
.add(
28-
'name me',
29-
() => render({})
30-
);
26+
const meta: Meta<Spectrum{{componentName}}Props> = {
27+
title: '{{componentName}}',
28+
component: {{componentName}}
29+
};
3130

32-
function render(props: Spectrum{{componentName}}Props = {}) {
33-
return (
34-
<{{componentName}} {...props} />
35-
);
36-
}
31+
export default meta;
32+
33+
const Template = (): Story<Spectrum{{componentName}}Props> => (args) => (
34+
<{{componentName}} {...args}>This is a React Spectrum {{componentName}}</{{componentName}}>
35+
);
36+
37+
export const Default = Template().bind({});
38+
Default.args = {};

plop-templates/@react-spectrum/stories/Component.stories.tsx.hbs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,29 @@
1111
*/
1212

1313
import {action} from '@storybook/addon-actions';
14-
{{#if (includes scopes "@react-types")}}
1514
import { {{~componentName~}} } from '../';
15+
import {Meta, Story} from '@storybook/react';
16+
import React from 'react';
17+
{{#if (includes scopes "@react-types")}}
1618
import {Spectrum{{componentName}}Props} from '@react-types/{{packageName}}';
17-
{{else}}
18-
import { {{~componentName}}, Spectrum{{componentName}}Props} from '../';
1919
{{/if}}
20-
import React from 'react';
21-
import {storiesOf} from '@storybook/react';
20+
{{#unless (includes scopes "@react-types")}}
2221

23-
storiesOf('{{componentName}}', module)
24-
.add(
25-
'name me',
26-
() => render({})
27-
);
22+
interface Spectrum{{componentName}}Props {
2823

29-
function render(props: Spectrum{{componentName}}Props) {
30-
return (
31-
<{{componentName}} {...props} onChange={action('onChange')} />
32-
);
3324
}
25+
{{/unless}}
26+
27+
const meta: Meta<Spectrum{{componentName}}Props> = {
28+
title: '{{componentName}}',
29+
component: {{componentName}}
30+
};
31+
32+
export default meta;
33+
34+
const Template = (): Story<Spectrum{{componentName}}Props> => (args) => (
35+
<{{componentName}} {...args}>This is a React Spectrum {{componentName}}</{{componentName}}>
36+
);
37+
38+
export const Default = Template().bind({});
39+
Default.args = {onChange: action('onChange')};

0 commit comments

Comments
 (0)