@storybook/svelte-vite 9.0.0-alpha.0 → 9.0.0-alpha.10
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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/preset.d.ts +1 -0
- package/dist/preset.js +2 -2
- package/package.json +6 -5
- package/template/cli/js/Button.stories.js +43 -0
- package/template/cli/js/Button.svelte +36 -0
- package/template/cli/js/Header.stories.js +22 -0
- package/template/cli/js/Header.svelte +52 -0
- package/template/cli/js/Page.stories.js +28 -0
- package/template/cli/js/Page.svelte +70 -0
- package/template/cli/svelte-5-js/Button.stories.svelte +31 -0
- package/template/cli/svelte-5-js/Button.svelte +26 -0
- package/template/cli/svelte-5-js/Header.stories.svelte +26 -0
- package/template/cli/svelte-5-js/Header.svelte +47 -0
- package/template/cli/svelte-5-js/Page.stories.svelte +30 -0
- package/template/cli/svelte-5-js/Page.svelte +70 -0
- package/template/cli/svelte-5-ts-3-8/Button.stories.svelte +31 -0
- package/template/cli/svelte-5-ts-3-8/Button.svelte +29 -0
- package/template/cli/svelte-5-ts-3-8/Header.stories.svelte +26 -0
- package/template/cli/svelte-5-ts-3-8/Header.svelte +45 -0
- package/template/cli/svelte-5-ts-3-8/Page.stories.svelte +30 -0
- package/template/cli/svelte-5-ts-3-8/Page.svelte +70 -0
- package/template/cli/svelte-5-ts-4-9/Button.stories.svelte +31 -0
- package/template/cli/svelte-5-ts-4-9/Button.svelte +29 -0
- package/template/cli/svelte-5-ts-4-9/Header.stories.svelte +26 -0
- package/template/cli/svelte-5-ts-4-9/Header.svelte +45 -0
- package/template/cli/svelte-5-ts-4-9/Page.stories.svelte +30 -0
- package/template/cli/svelte-5-ts-4-9/Page.svelte +70 -0
- package/template/cli/ts-4-9/Button.stories.ts +48 -0
- package/template/cli/ts-4-9/Button.svelte +34 -0
- package/template/cli/ts-4-9/Header.stories.ts +27 -0
- package/template/cli/ts-4-9/Header.svelte +52 -0
- package/template/cli/ts-4-9/Page.stories.ts +33 -0
- package/template/cli/ts-4-9/Page.svelte +70 -0
- package/template/stories_svelte-vite-default-ts/DocsTS.svelte +97 -0
- package/template/stories_svelte-vite-default-ts/types.ts +7 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import './page.css';
|
|
3
|
+
import Header from './Header.svelte';
|
|
4
|
+
|
|
5
|
+
let user: { name: string } | null = null;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<article>
|
|
9
|
+
<Header
|
|
10
|
+
{user}
|
|
11
|
+
on:login={() => (user = { name: 'Jane Doe' })}
|
|
12
|
+
on:logout={() => (user = null)}
|
|
13
|
+
on:createAccount={() => (user = { name: 'Jane Doe' })}
|
|
14
|
+
/>
|
|
15
|
+
|
|
16
|
+
<section class="storybook-page">
|
|
17
|
+
<h2>Pages in Storybook</h2>
|
|
18
|
+
<p>
|
|
19
|
+
We recommend building UIs with a
|
|
20
|
+
<a
|
|
21
|
+
href="https://blog.hichroma.com/component-driven-development-ce1109d56c8e"
|
|
22
|
+
target="_blank"
|
|
23
|
+
rel="noopener noreferrer"
|
|
24
|
+
>
|
|
25
|
+
<strong>component-driven</strong>
|
|
26
|
+
</a>
|
|
27
|
+
process starting with atomic components and ending with pages.
|
|
28
|
+
</p>
|
|
29
|
+
<p>
|
|
30
|
+
Render pages with mock data. This makes it easy to build and review page states without
|
|
31
|
+
needing to navigate to them in your app. Here are some handy patterns for managing page data
|
|
32
|
+
in Storybook:
|
|
33
|
+
</p>
|
|
34
|
+
<ul>
|
|
35
|
+
<li>
|
|
36
|
+
Use a higher-level connected component. Storybook helps you compose such data from the
|
|
37
|
+
"args" of child component stories
|
|
38
|
+
</li>
|
|
39
|
+
<li>
|
|
40
|
+
Assemble data in the page component from your services. You can mock these services out
|
|
41
|
+
using Storybook.
|
|
42
|
+
</li>
|
|
43
|
+
</ul>
|
|
44
|
+
<p>
|
|
45
|
+
Get a guided tutorial on component-driven development at
|
|
46
|
+
<a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
|
|
47
|
+
Storybook tutorials
|
|
48
|
+
</a>
|
|
49
|
+
. Read more in the
|
|
50
|
+
<a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">docs</a>
|
|
51
|
+
.
|
|
52
|
+
</p>
|
|
53
|
+
<div class="tip-wrapper">
|
|
54
|
+
<span class="tip">Tip</span>
|
|
55
|
+
Adjust the width of the canvas with the
|
|
56
|
+
<svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
|
|
57
|
+
<g fill="none" fill-rule="evenodd">
|
|
58
|
+
<path
|
|
59
|
+
d="M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0
|
|
60
|
+
01-.5-.4V5.7c0-.3.2-.5.5-.5zm0-2.1h6.9c.3 0 .5.2.5.4v7a.5.5 0 01-1 0V4H1.5a.5.5 0
|
|
61
|
+
010-1zm0-2.1h9c.3 0 .5.2.5.4v9.1a.5.5 0 01-1 0V2H1.5a.5.5 0 010-1zm4.3 5.2H2V10h3.8V6.2z"
|
|
62
|
+
id="a"
|
|
63
|
+
fill="#999"
|
|
64
|
+
/>
|
|
65
|
+
</g>
|
|
66
|
+
</svg>
|
|
67
|
+
Viewports addon in the toolbar
|
|
68
|
+
</div>
|
|
69
|
+
</section>
|
|
70
|
+
</article>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { LiteralNumbers, LiteralStrings } from './types';
|
|
3
|
+
import { MyEnum } from './types';
|
|
4
|
+
|
|
5
|
+
type MyObject = {
|
|
6
|
+
foo: string;
|
|
7
|
+
bar: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Boolean
|
|
12
|
+
*/
|
|
13
|
+
export let boolean: boolean = true;
|
|
14
|
+
/**
|
|
15
|
+
* String
|
|
16
|
+
*/
|
|
17
|
+
export let string: string = 'default';
|
|
18
|
+
/**
|
|
19
|
+
* String (required)
|
|
20
|
+
*/
|
|
21
|
+
export let stringRequired: string;
|
|
22
|
+
/**
|
|
23
|
+
* Number
|
|
24
|
+
*/
|
|
25
|
+
export let number: number = 123;
|
|
26
|
+
/**
|
|
27
|
+
* True literal
|
|
28
|
+
*/
|
|
29
|
+
export let trueLiteral: true | undefined = undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Symbol
|
|
32
|
+
*/
|
|
33
|
+
export let symbol: symbol | undefined = undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Null
|
|
36
|
+
*/
|
|
37
|
+
export let nullValue: null = null;
|
|
38
|
+
/**
|
|
39
|
+
* Undefined
|
|
40
|
+
*/
|
|
41
|
+
export let undefinedValue: undefined = undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Any
|
|
44
|
+
*/
|
|
45
|
+
export let any: any = null;
|
|
46
|
+
/**
|
|
47
|
+
* Date
|
|
48
|
+
*/
|
|
49
|
+
export let date: Date = new Date('20 Jan 1983');
|
|
50
|
+
/**
|
|
51
|
+
* Array of numbers
|
|
52
|
+
*/
|
|
53
|
+
export let arrayOfNumbers: number[] = [1, 20, 300];
|
|
54
|
+
/**
|
|
55
|
+
* Enum
|
|
56
|
+
*/
|
|
57
|
+
export let enumValue: MyEnum = MyEnum.FOO;
|
|
58
|
+
/**
|
|
59
|
+
* Union of literal strings
|
|
60
|
+
*/
|
|
61
|
+
export let unionLiteralStrings: LiteralStrings = 'apple';
|
|
62
|
+
/**
|
|
63
|
+
* Union of literal numbers
|
|
64
|
+
*/
|
|
65
|
+
export let unionLiteralNumbers: LiteralNumbers = 100;
|
|
66
|
+
/**
|
|
67
|
+
* Object
|
|
68
|
+
*/
|
|
69
|
+
export let object: MyObject | undefined = undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Inline object
|
|
72
|
+
*/
|
|
73
|
+
export let inlineObject:
|
|
74
|
+
| {
|
|
75
|
+
foo: string;
|
|
76
|
+
bar: number;
|
|
77
|
+
}
|
|
78
|
+
| undefined = undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Record
|
|
81
|
+
*/
|
|
82
|
+
export let record: Record<string, number> = { a: 1, b: 2 };
|
|
83
|
+
/**
|
|
84
|
+
* Union of types
|
|
85
|
+
*/
|
|
86
|
+
export let unionTypes: number | string = 123;
|
|
87
|
+
/**
|
|
88
|
+
* Intersection of types
|
|
89
|
+
*/
|
|
90
|
+
export let intersection: ({ a: number } & { b: string }) | undefined = undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Event callback function
|
|
93
|
+
*/
|
|
94
|
+
export let func: (event: MouseEvent) => number = () => 10;
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<div>Docs: TS</div>
|