-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
index.story.tsx
115 lines (102 loc) · 2.37 KB
/
index.story.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
* External dependencies
*/
import type { Meta, StoryFn } from '@storybook/react';
import type { ReactNode } from 'react';
/**
* WordPress dependencies
*/
import {
formatBold,
formatItalic,
link,
more,
wordpress,
} from '@wordpress/icons';
/**
* Internal dependencies
*/
import './style.css';
import Button from '..';
const meta: Meta< typeof Button > = {
title: 'Components/Button',
component: Button,
argTypes: {
// Overrides a limitation of the docgen interpreting our TS types for this as required.
'aria-pressed': {
control: { type: 'select' },
description:
'Indicates the current "pressed" state, implying it is a toggle button. Implicitly set by `isPressed`, but takes precedence if both are provided.',
options: [ undefined, 'true', 'false', 'mixed' ],
table: {
type: {
summary: 'boolean | "true" | "false" | "mixed"',
},
},
},
href: { type: { name: 'string', required: false } },
icon: {
control: { type: 'select' },
options: [ 'wordpress', 'link', 'more' ],
mapping: {
wordpress,
link,
more,
},
},
},
parameters: {
controls: { expanded: true },
docs: { canvas: { sourceState: 'shown' } },
},
};
export default meta;
const Template: StoryFn< typeof Button > = ( props ) => {
return <Button { ...props }></Button>;
};
export const Default = Template.bind( {} );
Default.args = {
children: 'Code is poetry',
};
export const Primary = Template.bind( {} );
Primary.args = {
...Default.args,
variant: 'primary',
};
export const Secondary = Template.bind( {} );
Secondary.args = {
...Default.args,
variant: 'secondary',
};
export const Tertiary = Template.bind( {} );
Tertiary.args = {
...Default.args,
variant: 'tertiary',
};
export const Link = Template.bind( {} );
Link.args = {
...Default.args,
variant: 'link',
};
export const IsDestructive = Template.bind( {} );
IsDestructive.args = {
...Default.args,
isDestructive: true,
};
export const Icon = Template.bind( {} );
Icon.args = {
label: 'Code is poetry',
icon: 'wordpress',
};
export const GroupedIcons = () => {
const GroupContainer = ( { children }: { children: ReactNode } ) => (
<div style={ { display: 'inline-flex' } }>{ children }</div>
);
return (
<GroupContainer>
<Button icon={ formatBold } label="Bold" />
<Button icon={ formatItalic } label="Italic" />
<Button icon={ link } label="Link" />
</GroupContainer>
);
};