/
button.stories.tsx
59 lines (50 loc) · 1.46 KB
/
button.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* eslint-disable storybook/await-interactions */
/* eslint-disable storybook/use-storybook-testing-library */
// @TODO: use addon-interactions and remove the rule disable above
import React from 'react';
import { Meta, ComponentStory } from '@storybook/react';
import { screen } from '@testing-library/dom';
import userEvent from '@testing-library/user-event';
import { Button } from './button';
export default {
component: Button,
title: 'Examples / Button',
argTypes: { onClick: { action: 'click ' } },
// render: () => <>hohoho</>,
} as Meta;
export const WithArgs: ComponentStory<typeof Button> = (args) => <Button {...args} />;
WithArgs.args = { label: 'With args' };
export const Basic = () => <Button label="Click me" />;
export const StoryObject = {
render: () => <>hahaha</>,
};
export const StoryNoRender = {
args: { label: 'magic!' },
};
export const ProcessEnv = {
args: { label: process.env.FOO },
play: () => {
process.env.BAZ = 'moo';
},
};
export const StoryWithPlay = {
args: { label: 'play' },
play: () => {
console.log('play!!');
userEvent.click(screen.getByRole('button'));
},
};
export const CSF2StoryWithPlay = WithArgs.bind({});
CSF2StoryWithPlay.play = () => {
console.log('play!!');
userEvent.click(screen.getByRole('button'));
};
// eslint-disable-next-line no-underscore-dangle
export const __namedExportsOrder = [
'Basic',
'WithArgs',
'StoryObject',
'StoryNoRender',
'StoryWithPlay',
'CSF2StoryWithPlay',
];