@acusti/uikit-docs 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.ts +28 -0
- package/.storybook/manager.ts +8 -0
- package/.storybook/preview.ts +19 -0
- package/README.md +6 -0
- package/package.json +26 -0
- package/stories/Button.stories.ts +50 -0
- package/stories/Button.tsx +48 -0
- package/stories/CSSValueInput.css +38 -0
- package/stories/CSSValueInput.stories.tsx +171 -0
- package/stories/DatePicker.css +3 -0
- package/stories/DatePicker.stories.tsx +99 -0
- package/stories/Dropdown.css +149 -0
- package/stories/Dropdown.stories.tsx +446 -0
- package/stories/Header.stories.ts +27 -0
- package/stories/Header.tsx +66 -0
- package/stories/InputText.css +15 -0
- package/stories/InputText.stories.tsx +152 -0
- package/stories/Introduction.mdx +388 -0
- package/stories/MonthCalendar.css +3 -0
- package/stories/MonthCalendar.stories.ts +57 -0
- package/stories/Page.stories.ts +29 -0
- package/stories/Page.tsx +91 -0
- package/stories/assets/accessibility.png +0 -0
- package/stories/assets/accessibility.svg +5 -0
- package/stories/assets/addon-library.png +0 -0
- package/stories/assets/assets.png +0 -0
- package/stories/assets/context.png +0 -0
- package/stories/assets/discord.svg +15 -0
- package/stories/assets/docs.png +0 -0
- package/stories/assets/figma-plugin.png +0 -0
- package/stories/assets/github.svg +3 -0
- package/stories/assets/share.png +0 -0
- package/stories/assets/styling.png +0 -0
- package/stories/assets/testing.png +0 -0
- package/stories/assets/theming.png +0 -0
- package/stories/assets/tutorials.svg +12 -0
- package/stories/assets/youtube.svg +4 -0
- package/stories/button.css +30 -0
- package/stories/header.css +32 -0
- package/stories/page.css +69 -0
- package/stories/useIsOutOfBounds.css +16 -0
- package/stories/useIsOutOfBounds.stories.tsx +164 -0
- package/stories/useKeyboardEvents.css +19 -0
- package/stories/useKeyboardEvents.stories.tsx +104 -0
- package/tsconfig.json +3 -0
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { fn } from '@storybook/test';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import CSSValueInput from '../../css-value-input/src/CSSValueInput.js';
|
|
5
|
+
import Dropdown from '../../dropdown/src/Dropdown.js';
|
|
6
|
+
|
|
7
|
+
import './CSSValueInput.css';
|
|
8
|
+
import './Dropdown.css';
|
|
9
|
+
import './InputText.css';
|
|
10
|
+
|
|
11
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
12
|
+
|
|
13
|
+
const { Fragment } = React;
|
|
14
|
+
|
|
15
|
+
const meta: Meta<typeof Dropdown> = {
|
|
16
|
+
component: Dropdown,
|
|
17
|
+
parameters: {
|
|
18
|
+
docs: {
|
|
19
|
+
description: {
|
|
20
|
+
component:
|
|
21
|
+
'`Dropdown` is a React component that renders a menu-like UI with a trigger that the user clicks to disclose a dropdown positioned below the trigger. The body of the dropdown can include any DOM, and many dropdowns can be combined to form a multi-item menu, like the system menu in the top toolbar of macOS.',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
//https://storybook.js.org/docs/react/writing-docs/autodocs#setup-automated-documentation
|
|
26
|
+
tags: ['autodocs'],
|
|
27
|
+
title: 'UIKit/Controls/Dropdown',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default meta;
|
|
31
|
+
|
|
32
|
+
type Story = StoryObj<typeof Dropdown>;
|
|
33
|
+
|
|
34
|
+
export const CSSLengthsDropdown: Story = {
|
|
35
|
+
args: {
|
|
36
|
+
children: (
|
|
37
|
+
<ul>
|
|
38
|
+
<li>0px</li>
|
|
39
|
+
<li>4px</li>
|
|
40
|
+
<li>9px</li>
|
|
41
|
+
<li>18px</li>
|
|
42
|
+
<li>36px</li>
|
|
43
|
+
<li>54px</li>
|
|
44
|
+
<li>72px</li>
|
|
45
|
+
<li>144px</li>
|
|
46
|
+
<li>167px</li>
|
|
47
|
+
<li>198px</li>
|
|
48
|
+
</ul>
|
|
49
|
+
),
|
|
50
|
+
className: 'css-lengths no-trigger-text',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const StatesDropdown: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
children: (
|
|
57
|
+
<ul>
|
|
58
|
+
<li>Alabama</li>
|
|
59
|
+
<li>Alaska</li>
|
|
60
|
+
<li>Arizona</li>
|
|
61
|
+
<li>Arkansas</li>
|
|
62
|
+
<li>California</li>
|
|
63
|
+
<li>Colorado</li>
|
|
64
|
+
<li>Connecticut</li>
|
|
65
|
+
<li>Delaware</li>
|
|
66
|
+
<li>Florida</li>
|
|
67
|
+
<li>Georgia</li>
|
|
68
|
+
<li>Hawaii</li>
|
|
69
|
+
<li>Idaho</li>
|
|
70
|
+
<li>Illinois</li>
|
|
71
|
+
<li>Indiana</li>
|
|
72
|
+
<li>Iowa</li>
|
|
73
|
+
<li>Kansas</li>
|
|
74
|
+
<li>Kentucky</li>
|
|
75
|
+
<li>Louisiana</li>
|
|
76
|
+
<li>Maine</li>
|
|
77
|
+
<li>Maryland</li>
|
|
78
|
+
<li>Massachusetts</li>
|
|
79
|
+
<li>Michigan</li>
|
|
80
|
+
<li>Minnesota</li>
|
|
81
|
+
<li>Mississippi</li>
|
|
82
|
+
<li>Missouri</li>
|
|
83
|
+
<li>Montana</li>
|
|
84
|
+
<li>Nebraska</li>
|
|
85
|
+
<li>Nevada</li>
|
|
86
|
+
<li>New Hampshire</li>
|
|
87
|
+
<li>New Jersey</li>
|
|
88
|
+
<li>New Mexico</li>
|
|
89
|
+
<li>New York</li>
|
|
90
|
+
<li>North Carolina</li>
|
|
91
|
+
<li>North Dakota</li>
|
|
92
|
+
<li>Ohio</li>
|
|
93
|
+
<li>Oklahoma</li>
|
|
94
|
+
<li>Oregon</li>
|
|
95
|
+
<li>Pennsylvania</li>
|
|
96
|
+
<li>Rhode Island</li>
|
|
97
|
+
<li>South Carolina</li>
|
|
98
|
+
<li>South Dakota</li>
|
|
99
|
+
<li>Tennessee</li>
|
|
100
|
+
<li>Texas</li>
|
|
101
|
+
<li>Utah</li>
|
|
102
|
+
<li>Vermont</li>
|
|
103
|
+
<li>Virginia</li>
|
|
104
|
+
<li>Washington</li>
|
|
105
|
+
<li>West Virginia</li>
|
|
106
|
+
<li>Wisconsin</li>
|
|
107
|
+
<li>Wyoming</li>
|
|
108
|
+
</ul>
|
|
109
|
+
),
|
|
110
|
+
className: 'states-dropdown',
|
|
111
|
+
isSearchable: true,
|
|
112
|
+
placeholder: 'Choose a state…',
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const FontWeightDropdown: Story = {
|
|
117
|
+
args: {
|
|
118
|
+
children: (
|
|
119
|
+
<ul>
|
|
120
|
+
<li data-ukt-value="100">
|
|
121
|
+
<span className="item-title">Font Weight - </span>
|
|
122
|
+
100
|
|
123
|
+
</li>
|
|
124
|
+
<li data-ukt-value="200">
|
|
125
|
+
<span className="item-title">Font Weight - </span>
|
|
126
|
+
200
|
|
127
|
+
</li>
|
|
128
|
+
<li data-ukt-value="300">
|
|
129
|
+
<span className="item-title">Font Weight - </span>
|
|
130
|
+
300
|
|
131
|
+
</li>
|
|
132
|
+
<li data-ukt-value="400">
|
|
133
|
+
<span className="item-title">Font Weight - </span>
|
|
134
|
+
400
|
|
135
|
+
</li>
|
|
136
|
+
<li data-ukt-value="500">
|
|
137
|
+
<span className="item-title">Font Weight - </span>
|
|
138
|
+
500
|
|
139
|
+
</li>
|
|
140
|
+
<li data-ukt-value="600">
|
|
141
|
+
<span className="item-title">Font Weight - </span>
|
|
142
|
+
600
|
|
143
|
+
</li>
|
|
144
|
+
<li data-ukt-value="700">
|
|
145
|
+
<span className="item-title">Font Weight - </span>
|
|
146
|
+
700
|
|
147
|
+
</li>
|
|
148
|
+
</ul>
|
|
149
|
+
),
|
|
150
|
+
className: 'font-weight',
|
|
151
|
+
isSearchable: true,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const ShowContextMenuOnMount: Story = {
|
|
156
|
+
args: {
|
|
157
|
+
children: [
|
|
158
|
+
'View menu',
|
|
159
|
+
<Fragment>
|
|
160
|
+
<h4 className="heading">View</h4>
|
|
161
|
+
<ul>
|
|
162
|
+
<li data-ukt-item>Open</li>
|
|
163
|
+
<li data-ukt-item>Preview</li>
|
|
164
|
+
</ul>
|
|
165
|
+
<h4 className="heading">Edit</h4>
|
|
166
|
+
<ul>
|
|
167
|
+
<li data-ukt-value="save-item">Save</li>
|
|
168
|
+
<li data-ukt-value="edit-item">Edit</li>
|
|
169
|
+
<li data-ukt-value="delete-item">Delete</li>
|
|
170
|
+
</ul>
|
|
171
|
+
</Fragment>,
|
|
172
|
+
],
|
|
173
|
+
className: 'open-on-mount-context-menu',
|
|
174
|
+
isOpenOnMount: true,
|
|
175
|
+
// NOTE spies are a workaround for a bug related to implicit arg detection
|
|
176
|
+
// https://github.com/storybookjs/storybook/issues/23873
|
|
177
|
+
onClick: fn(),
|
|
178
|
+
onClose: fn(),
|
|
179
|
+
onMouseDown: fn(),
|
|
180
|
+
onMouseUp: fn(),
|
|
181
|
+
onOpen: fn(),
|
|
182
|
+
onSubmitItem: fn(),
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const DropdownWithInteractiveContents: Story = {
|
|
187
|
+
args: {
|
|
188
|
+
children: [
|
|
189
|
+
'Open',
|
|
190
|
+
<div>
|
|
191
|
+
<p>
|
|
192
|
+
Try interacting with the controls here. The dropdown should only close
|
|
193
|
+
when you click outside of the entire dropdown or if you hit the escape
|
|
194
|
+
key when focus isn’t in the input controls.
|
|
195
|
+
</p>
|
|
196
|
+
<CSSValueInput
|
|
197
|
+
cssValueType="length"
|
|
198
|
+
label="Width"
|
|
199
|
+
onSubmitValue={() => {}}
|
|
200
|
+
placeholder="100vw"
|
|
201
|
+
unit="vw"
|
|
202
|
+
/>
|
|
203
|
+
<CSSValueInput
|
|
204
|
+
cssValueType="length"
|
|
205
|
+
label="Rotation"
|
|
206
|
+
onSubmitValue={() => {}}
|
|
207
|
+
placeholder="0deg"
|
|
208
|
+
step={5}
|
|
209
|
+
unit="deg"
|
|
210
|
+
/>
|
|
211
|
+
</div>,
|
|
212
|
+
],
|
|
213
|
+
className: 'dropdown-without-items',
|
|
214
|
+
hasItems: false,
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export const SearchableWithLabel: Story = {
|
|
219
|
+
args: {
|
|
220
|
+
children: (
|
|
221
|
+
<ul>
|
|
222
|
+
<li>0px</li>
|
|
223
|
+
<li>4px</li>
|
|
224
|
+
<li>9px</li>
|
|
225
|
+
<li>18px</li>
|
|
226
|
+
<li>36px</li>
|
|
227
|
+
<li>54px</li>
|
|
228
|
+
<li>72px</li>
|
|
229
|
+
<li>144px</li>
|
|
230
|
+
<li>167px</li>
|
|
231
|
+
<li>198px</li>
|
|
232
|
+
</ul>
|
|
233
|
+
),
|
|
234
|
+
className: 'searchable-with-label',
|
|
235
|
+
isSearchable: true,
|
|
236
|
+
label: 'Font size',
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
export const SearchableAndAllowCreate: Story = {
|
|
241
|
+
args: {
|
|
242
|
+
allowCreate: true,
|
|
243
|
+
children: (
|
|
244
|
+
<ul>
|
|
245
|
+
<li>0px</li>
|
|
246
|
+
<li>4px</li>
|
|
247
|
+
<li>9px</li>
|
|
248
|
+
<li>18px</li>
|
|
249
|
+
<li>36px</li>
|
|
250
|
+
<li>54px</li>
|
|
251
|
+
<li>72px</li>
|
|
252
|
+
<li>144px</li>
|
|
253
|
+
<li>167px</li>
|
|
254
|
+
<li>198px</li>
|
|
255
|
+
</ul>
|
|
256
|
+
),
|
|
257
|
+
className: 'searchable-and-allow-create',
|
|
258
|
+
isSearchable: true,
|
|
259
|
+
label: 'Font size',
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
export const CSSValueInputTrigger: Story = {
|
|
264
|
+
args: {
|
|
265
|
+
allowCreate: true,
|
|
266
|
+
children: [
|
|
267
|
+
<CSSValueInput
|
|
268
|
+
name="cssinputbackgroundsize"
|
|
269
|
+
onSubmitValue={() => {}}
|
|
270
|
+
placeholder="cover"
|
|
271
|
+
validator={/^(auto|contain|cover)$/}
|
|
272
|
+
/>,
|
|
273
|
+
<ul>
|
|
274
|
+
<li>cover</li>
|
|
275
|
+
<li>contain</li>
|
|
276
|
+
<li>auto</li>
|
|
277
|
+
<li>50px</li>
|
|
278
|
+
<li>100px</li>
|
|
279
|
+
<li>200px</li>
|
|
280
|
+
<li>50%</li>
|
|
281
|
+
</ul>,
|
|
282
|
+
],
|
|
283
|
+
className: 'css-value-input-trigger',
|
|
284
|
+
hasItems: true,
|
|
285
|
+
label: 'Background size',
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
export const TextareaTrigger: Story = {
|
|
290
|
+
args: {
|
|
291
|
+
children: [
|
|
292
|
+
<textarea></textarea>,
|
|
293
|
+
<ul>
|
|
294
|
+
<li>
|
|
295
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque
|
|
296
|
+
ullamcorper fringilla quam, vel tincidunt nisl mattis vel.
|
|
297
|
+
</li>
|
|
298
|
+
<li>
|
|
299
|
+
Aenean posuere erat sed enim luctus, et accumsan nisl elementum. Nulla
|
|
300
|
+
vel blandit urna, vel accumsan nulla. Nulla varius luctus ex, gravida
|
|
301
|
+
ultrices orci sagittis eu.
|
|
302
|
+
</li>
|
|
303
|
+
<li>
|
|
304
|
+
Quisque vitae magna euismod ligula molestie maximus id et nunc. Nam et
|
|
305
|
+
lacus euismod, porttitor massa vel, sollicitudin ex. Sed ut tellus
|
|
306
|
+
suscipit, faucibus tortor nec, fermentum mi.
|
|
307
|
+
</li>
|
|
308
|
+
<li>
|
|
309
|
+
Nulla sagittis justo non accumsan sagittis. Cras a eros et dolor
|
|
310
|
+
dapibus bibendum lobortis quis ante. Ut eget scelerisque massa.
|
|
311
|
+
</li>
|
|
312
|
+
<li>
|
|
313
|
+
Vestibulum quis dignissim nunc. Mauris fringilla at nulla non lacinia.
|
|
314
|
+
Etiam tristique elit non nisl finibus, fringilla hendrerit ligula
|
|
315
|
+
hendrerit. Fusce eget leo lacinia, eleifend diam non, suscipit purus.
|
|
316
|
+
</li>
|
|
317
|
+
</ul>,
|
|
318
|
+
],
|
|
319
|
+
className: 'textarea-trigger',
|
|
320
|
+
hasItems: true,
|
|
321
|
+
},
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
export const CheckboxesDropdown: Story = {
|
|
325
|
+
args: {
|
|
326
|
+
children: [
|
|
327
|
+
'Colors',
|
|
328
|
+
<ul>
|
|
329
|
+
<li>
|
|
330
|
+
<label>
|
|
331
|
+
<input type="checkbox" /> Red
|
|
332
|
+
</label>
|
|
333
|
+
</li>
|
|
334
|
+
<li>
|
|
335
|
+
<label>
|
|
336
|
+
<input type="checkbox" /> Blue
|
|
337
|
+
</label>
|
|
338
|
+
</li>
|
|
339
|
+
<li>
|
|
340
|
+
<label>
|
|
341
|
+
<input type="checkbox" /> Yellow
|
|
342
|
+
</label>
|
|
343
|
+
</li>
|
|
344
|
+
<li>
|
|
345
|
+
<label>
|
|
346
|
+
<input type="checkbox" /> Cyan
|
|
347
|
+
</label>
|
|
348
|
+
</li>
|
|
349
|
+
<li>
|
|
350
|
+
<label>
|
|
351
|
+
<input type="checkbox" /> Orchid
|
|
352
|
+
</label>
|
|
353
|
+
</li>
|
|
354
|
+
<li>
|
|
355
|
+
<label>
|
|
356
|
+
<input type="checkbox" /> Slate
|
|
357
|
+
</label>
|
|
358
|
+
</li>
|
|
359
|
+
</ul>,
|
|
360
|
+
],
|
|
361
|
+
className: 'checkboxes',
|
|
362
|
+
keepOpenOnSubmit: true,
|
|
363
|
+
},
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export const DisabledDropdown: Story = {
|
|
367
|
+
args: {
|
|
368
|
+
children: (
|
|
369
|
+
<ul>
|
|
370
|
+
<li>0px</li>
|
|
371
|
+
<li>4px</li>
|
|
372
|
+
<li>9px</li>
|
|
373
|
+
<li>18px</li>
|
|
374
|
+
<li>36px</li>
|
|
375
|
+
<li>54px</li>
|
|
376
|
+
<li>72px</li>
|
|
377
|
+
<li>144px</li>
|
|
378
|
+
<li>167px</li>
|
|
379
|
+
<li>198px</li>
|
|
380
|
+
</ul>
|
|
381
|
+
),
|
|
382
|
+
className: 'disabled-dropdown',
|
|
383
|
+
disabled: true,
|
|
384
|
+
isSearchable: true,
|
|
385
|
+
label: 'Disabled',
|
|
386
|
+
name: 'disabledexample',
|
|
387
|
+
value: '167px',
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
export const OverlappingDropdown: Story = {
|
|
392
|
+
args: {
|
|
393
|
+
children: (
|
|
394
|
+
<ul>
|
|
395
|
+
<li>the carbon in our apple pies</li>
|
|
396
|
+
<li>sea of tranquility tesseract</li>
|
|
397
|
+
<li>encyclopaedia galactica</li>
|
|
398
|
+
<li>billions upon billions</li>
|
|
399
|
+
<li>network of wormholes</li>
|
|
400
|
+
<li>tingling of the spine</li>
|
|
401
|
+
<li>corpus callosum</li>
|
|
402
|
+
<li>finite but unbounded</li>
|
|
403
|
+
</ul>
|
|
404
|
+
),
|
|
405
|
+
className: 'overlapping-dropdown no-trigger-text',
|
|
406
|
+
},
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
export const OutOfBoundsAtRight: Story = {
|
|
410
|
+
args: {
|
|
411
|
+
children: (
|
|
412
|
+
<ul>
|
|
413
|
+
<li>0px</li>
|
|
414
|
+
<li>4px</li>
|
|
415
|
+
<li>9px</li>
|
|
416
|
+
<li>18px</li>
|
|
417
|
+
<li>36px</li>
|
|
418
|
+
<li>54px</li>
|
|
419
|
+
<li>72px</li>
|
|
420
|
+
<li>144px</li>
|
|
421
|
+
<li>167px</li>
|
|
422
|
+
<li>198px</li>
|
|
423
|
+
</ul>
|
|
424
|
+
),
|
|
425
|
+
className: 'out-of-bounds-example position-right',
|
|
426
|
+
isSearchable: true,
|
|
427
|
+
name: 'outofboundsatright',
|
|
428
|
+
placeholder: 'Show above & to the left',
|
|
429
|
+
},
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
export const OutOfBoundsWithNoDirectionChange: Story = {
|
|
433
|
+
args: {
|
|
434
|
+
children: (
|
|
435
|
+
<ul>
|
|
436
|
+
<li>Antarctica</li>
|
|
437
|
+
<li>Arctic Circle</li>
|
|
438
|
+
<li>North Pole</li>
|
|
439
|
+
</ul>
|
|
440
|
+
),
|
|
441
|
+
className: 'out-of-bounds-example no-direction-change',
|
|
442
|
+
isSearchable: true,
|
|
443
|
+
name: 'outofboundsatbottomnodirectionchange',
|
|
444
|
+
placeholder: 'Show below even though it goes out of bounds',
|
|
445
|
+
},
|
|
446
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { Header } from './Header';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Example/Header',
|
|
7
|
+
component: Header,
|
|
8
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
parameters: {
|
|
11
|
+
// More on how to position stories at: https://storybook.js.org/docs/react/configure/story-layout
|
|
12
|
+
layout: 'fullscreen',
|
|
13
|
+
},
|
|
14
|
+
} satisfies Meta<typeof Header>;
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryObj<typeof meta>;
|
|
18
|
+
|
|
19
|
+
export const LoggedIn: Story = {
|
|
20
|
+
args: {
|
|
21
|
+
user: {
|
|
22
|
+
name: 'Jane Doe',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const LoggedOut: Story = {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Button } from './Button';
|
|
4
|
+
import './header.css';
|
|
5
|
+
|
|
6
|
+
type User = {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
interface HeaderProps {
|
|
11
|
+
user?: User;
|
|
12
|
+
onLogin: () => void;
|
|
13
|
+
onLogout: () => void;
|
|
14
|
+
onCreateAccount: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => (
|
|
18
|
+
<header>
|
|
19
|
+
<div className="storybook-header">
|
|
20
|
+
<div>
|
|
21
|
+
<svg
|
|
22
|
+
width="32"
|
|
23
|
+
height="32"
|
|
24
|
+
viewBox="0 0 32 32"
|
|
25
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
26
|
+
>
|
|
27
|
+
<g fill="none" fillRule="evenodd">
|
|
28
|
+
<path
|
|
29
|
+
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
|
|
30
|
+
fill="#FFF"
|
|
31
|
+
/>
|
|
32
|
+
<path
|
|
33
|
+
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
|
|
34
|
+
fill="#555AB9"
|
|
35
|
+
/>
|
|
36
|
+
<path
|
|
37
|
+
d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
|
|
38
|
+
fill="#91BAF8"
|
|
39
|
+
/>
|
|
40
|
+
</g>
|
|
41
|
+
</svg>
|
|
42
|
+
<h1>Acme</h1>
|
|
43
|
+
</div>
|
|
44
|
+
<div>
|
|
45
|
+
{user ? (
|
|
46
|
+
<>
|
|
47
|
+
<span className="welcome">
|
|
48
|
+
Welcome, <b>{user.name}</b>!
|
|
49
|
+
</span>
|
|
50
|
+
<Button size="small" onClick={onLogout} label="Log out" />
|
|
51
|
+
</>
|
|
52
|
+
) : (
|
|
53
|
+
<>
|
|
54
|
+
<Button size="small" onClick={onLogin} label="Log in" />
|
|
55
|
+
<Button
|
|
56
|
+
primary
|
|
57
|
+
size="small"
|
|
58
|
+
onClick={onCreateAccount}
|
|
59
|
+
label="Sign up"
|
|
60
|
+
/>
|
|
61
|
+
</>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</header>
|
|
66
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
input.input-text {
|
|
2
|
+
width: 160px;
|
|
3
|
+
padding: 3px 6px;
|
|
4
|
+
font-family: system-ui, sans-serif;
|
|
5
|
+
font-size: 13px;
|
|
6
|
+
line-height: 13px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.input-text-double-click-to-edit {
|
|
10
|
+
border-color: transparent;
|
|
11
|
+
|
|
12
|
+
&:read-only {
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
}
|
|
15
|
+
}
|