forked from storybookjs/storybook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Welcome.tsx
188 lines (178 loc) 路 4.22 KB
/
Welcome.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import React from 'react';
import PropTypes from 'prop-types';
const Main = (props?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>) => (
<article
{...props}
style={{
padding: 15,
lineHeight: 1.4,
fontFamily: '"Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif',
backgroundColor: '#fff',
color: '#000',
}}
/>
);
const Title = ({
children,
...props
}: {
children: string;
props?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
}) => <h1 {...props}>{children}</h1>;
Title.propTypes = {
children: PropTypes.node,
};
Title.defaultProps = {
children: undefined,
};
const Note = (
props?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>
) => (
<p
{...props}
style={{
opacity: 0.5,
}}
/>
);
const InlineCode = (
props?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>
) => (
<code
{...props}
style={{
fontSize: 15,
fontWeight: 600,
padding: '2px 5px',
border: '1px solid #eae9e9',
borderRadius: 4,
backgroundColor: '#f3f2f2',
color: '#3a3a3a',
}}
/>
);
const Link = ({
children,
href,
target,
rel,
...props
}: {
children: string;
href: string;
target: string;
rel: string;
props?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
}) => (
<a
href={href}
{...props}
target={target}
rel={rel}
style={{
color: '#1474f3',
textDecoration: 'none',
borderBottom: '1px solid #1474f3',
paddingBottom: 2,
}}
>
{children}
</a>
);
Link.propTypes = {
href: PropTypes.string,
children: PropTypes.node,
};
Link.defaultProps = {
href: undefined,
children: undefined,
};
const NavButton = ({
children,
onClick,
...props
}: {
children: string;
onClick: (event: React.MouseEvent<HTMLElement>) => void;
props?: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
}) => (
<button
{...props}
type="button"
onClick={onClick}
style={{
color: '#1474f3',
textDecoration: 'none',
borderBottom: '1px solid #1474f3',
paddingBottom: 2,
borderTop: 'none',
borderRight: 'none',
borderLeft: 'none',
backgroundColor: 'transparent',
padding: 0,
cursor: 'pointer',
font: 'inherit',
}}
>
{children}
</button>
);
NavButton.propTypes = {
children: PropTypes.node,
};
NavButton.defaultProps = {
children: undefined,
};
const Welcome = ({ showApp }: { showApp: () => void }) => (
<Main>
<Title>Welcome to storybook</Title>
<p>This is a UI component dev environment for your app.</p>
<p>
We've added some basic stories inside the <InlineCode>src/stories</InlineCode> directory.
<br />A story is a single state of one or more UI components. You can have as many stories as
you want.
<br />
(Basically a story is like a visual test case.)
</p>
<p>
See these sample <NavButton onClick={showApp}>stories</NavButton> for a component called{' '}
<InlineCode>Button</InlineCode>.
</p>
<p>
Just like that, you can add your own components as stories.
<br />
You can also edit those components and see changes right away.
<br />
(Try editing the <InlineCode>Button</InlineCode> stories located at{' '}
<InlineCode>src/stories/index.js</InlineCode>
.)
</p>
<p>
Usually we create stories with smaller UI components in the app.
<br />
Have a look at the{' '}
<Link
href="https://storybook.js.org/basics/writing-stories"
target="_blank"
rel="noopener noreferrer"
>
Writing Stories
</Link>{' '}
section in our documentation.
</p>
<Note>
<b>NOTE:</b>
<br />
Have a look at the <InlineCode>.storybook/webpack.config.js</InlineCode> to add webpack
loaders and plugins you are using in this project.
</Note>
</Main>
);
Welcome.displayName = 'Welcome';
Welcome.propTypes = {
showApp: PropTypes.func,
};
Welcome.defaultProps = {
showApp: null,
};
export { Welcome as default };