@storybook/sveltekit 9.0.0-alpha.8 → 9.0.0-beta.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/package.json +9 -9
- package/template/cli/{svelte-5-ts-3-8 → js}/Button.stories.svelte +1 -1
- package/template/cli/js/Button.svelte +11 -20
- package/template/cli/js/Header.svelte +12 -17
- package/template/cli/{svelte-5-js → js}/Page.stories.svelte +1 -1
- package/template/cli/js/Page.svelte +4 -4
- package/template/cli/{svelte-5-ts-4-9 → ts}/Button.stories.svelte +1 -1
- package/template/cli/{svelte-5-ts-3-8 → ts}/Button.svelte +8 -7
- package/template/cli/{svelte-5-ts-4-9 → ts}/Header.svelte +3 -3
- package/template/cli/{svelte-5-ts-4-9 → ts}/Page.stories.svelte +1 -1
- package/template/stories_svelte-kit-skeleton-ts/modules/environment.stories.js +8 -0
- package/template/{stories_svelte-kit-prerelease-ts → stories_svelte-kit-skeleton-ts/modules}/forms.stories.js +1 -2
- package/template/{stories_svelte-kit-skeleton-js → stories_svelte-kit-skeleton-ts/modules}/hrefs.stories.js +1 -2
- package/template/{stories_svelte-kit-prerelease-ts → stories_svelte-kit-skeleton-ts/modules}/navigation.stories.js +1 -2
- package/template/stories_svelte-kit-skeleton-ts/modules/paths.stories.js +8 -0
- package/template/{stories_svelte-kit-prerelease-ts → stories_svelte-kit-skeleton-ts/modules}/stores.stories.js +1 -2
- package/template/cli/js/Button.stories.js +0 -43
- package/template/cli/js/Header.stories.js +0 -22
- package/template/cli/js/Page.stories.js +0 -28
- package/template/cli/svelte-5-js/Button.stories.svelte +0 -31
- package/template/cli/svelte-5-js/Button.svelte +0 -26
- package/template/cli/svelte-5-js/Header.svelte +0 -47
- package/template/cli/svelte-5-js/Page.svelte +0 -70
- package/template/cli/svelte-5-ts-3-8/Header.svelte +0 -45
- package/template/cli/svelte-5-ts-3-8/Page.stories.svelte +0 -30
- package/template/cli/svelte-5-ts-4-9/Button.svelte +0 -29
- package/template/cli/svelte-5-ts-4-9/Header.stories.svelte +0 -26
- package/template/cli/svelte-5-ts-4-9/Page.svelte +0 -70
- package/template/cli/ts-4-9/Button.stories.ts +0 -48
- package/template/cli/ts-4-9/Button.svelte +0 -34
- package/template/cli/ts-4-9/Header.stories.ts +0 -27
- package/template/cli/ts-4-9/Header.svelte +0 -52
- package/template/cli/ts-4-9/Page.stories.ts +0 -32
- package/template/cli/ts-4-9/Page.svelte +0 -70
- package/template/stories_svelte-kit-prerelease-ts/DocsJSDocRunes.svelte +0 -55
- package/template/stories_svelte-kit-prerelease-ts/DocsTSInlinePropTypes.svelte +0 -114
- package/template/stories_svelte-kit-prerelease-ts/DocsTSLegacy.svelte +0 -102
- package/template/stories_svelte-kit-prerelease-ts/DocsTSReferencedPropTypes.svelte +0 -118
- package/template/stories_svelte-kit-prerelease-ts/Forms.svelte +0 -7
- package/template/stories_svelte-kit-prerelease-ts/docs-jsdoc-runes.stories.js +0 -10
- package/template/stories_svelte-kit-prerelease-ts/docs-ts-inline-prop-types.stories.js +0 -10
- package/template/stories_svelte-kit-prerelease-ts/docs-ts-referenced-prop-types.stories.js +0 -10
- package/template/stories_svelte-kit-prerelease-ts/docs-ts.stories.js +0 -10
- package/template/stories_svelte-kit-prerelease-ts/hrefs.stories.js +0 -53
- package/template/stories_svelte-kit-prerelease-ts/types.ts +0 -7
- package/template/stories_svelte-kit-skeleton-js/Hrefs.svelte +0 -8
- package/template/stories_svelte-kit-skeleton-js/Navigation.svelte +0 -38
- package/template/stories_svelte-kit-skeleton-js/Stores.svelte +0 -17
- package/template/stories_svelte-kit-skeleton-js/environment.stories.js +0 -11
- package/template/stories_svelte-kit-skeleton-js/forms.stories.js +0 -27
- package/template/stories_svelte-kit-skeleton-js/navigation.stories.js +0 -121
- package/template/stories_svelte-kit-skeleton-js/paths.stories.js +0 -11
- package/template/stories_svelte-kit-skeleton-js/stores.stories.js +0 -116
- package/template/stories_svelte-kit-skeleton-ts/DocsTS.svelte +0 -97
- package/template/stories_svelte-kit-skeleton-ts/Environment.svelte +0 -8
- package/template/stories_svelte-kit-skeleton-ts/Forms.svelte +0 -7
- package/template/stories_svelte-kit-skeleton-ts/Hrefs.svelte +0 -8
- package/template/stories_svelte-kit-skeleton-ts/Navigation.svelte +0 -37
- package/template/stories_svelte-kit-skeleton-ts/Paths.svelte +0 -6
- package/template/stories_svelte-kit-skeleton-ts/Stores.svelte +0 -17
- package/template/stories_svelte-kit-skeleton-ts/docs-ts.stories.js +0 -10
- package/template/stories_svelte-kit-skeleton-ts/environment.stories.js +0 -11
- package/template/stories_svelte-kit-skeleton-ts/forms.stories.js +0 -27
- package/template/stories_svelte-kit-skeleton-ts/hrefs.stories.js +0 -53
- package/template/stories_svelte-kit-skeleton-ts/navigation.stories.js +0 -121
- package/template/stories_svelte-kit-skeleton-ts/paths.stories.js +0 -11
- package/template/stories_svelte-kit-skeleton-ts/stores.stories.js +0 -116
- package/template/stories_svelte-kit-skeleton-ts/types.ts +0 -7
- /package/template/cli/{svelte-5-js → js}/Header.stories.svelte +0 -0
- /package/template/cli/{svelte-5-ts-3-8 → ts}/Header.stories.svelte +0 -0
- /package/template/cli/{svelte-5-ts-3-8 → ts}/Page.svelte +0 -0
- /package/template/{stories_svelte-kit-skeleton-js → stories_svelte-kit-skeleton-ts/modules}/Environment.svelte +0 -0
- /package/template/{stories_svelte-kit-skeleton-js → stories_svelte-kit-skeleton-ts/modules}/Forms.svelte +0 -0
- /package/template/{stories_svelte-kit-prerelease-ts → stories_svelte-kit-skeleton-ts/modules}/Hrefs.svelte +0 -0
- /package/template/{stories_svelte-kit-prerelease-ts → stories_svelte-kit-skeleton-ts/modules}/Navigation.svelte +0 -0
- /package/template/{stories_svelte-kit-skeleton-js → stories_svelte-kit-skeleton-ts/modules}/Paths.svelte +0 -0
- /package/template/{stories_svelte-kit-prerelease-ts → stories_svelte-kit-skeleton-ts/modules}/Stores.svelte +0 -0
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import './button.css';
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
/** Is this the principal call to action on the page? */
|
|
6
|
-
primary?: boolean;
|
|
7
|
-
/** What background color to use */
|
|
8
|
-
backgroundColor?: string;
|
|
9
|
-
/** How large should the button be? */
|
|
10
|
-
size?: 'small' | 'medium' | 'large';
|
|
11
|
-
/** Button contents */
|
|
12
|
-
label: string;
|
|
13
|
-
/** The onclick event handler */
|
|
14
|
-
onClick?: () => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const { primary = false, backgroundColor, size = 'medium', label, onClick }: Props = $props();
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<button
|
|
21
|
-
type="button"
|
|
22
|
-
class={['storybook-button', `storybook-button--${size}`].join(' ')}
|
|
23
|
-
class:storybook-button--primary={primary}
|
|
24
|
-
class:storybook-button--secondary={!primary}
|
|
25
|
-
style:background-color={backgroundColor}
|
|
26
|
-
onclick={onClick}
|
|
27
|
-
>
|
|
28
|
-
{label}
|
|
29
|
-
</button>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import Header from './Header.svelte';
|
|
4
|
-
import { fn } from 'storybook/test';
|
|
5
|
-
|
|
6
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
-
const { Story } = defineMeta({
|
|
8
|
-
title: 'Example/Header',
|
|
9
|
-
component: Header,
|
|
10
|
-
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
11
|
-
tags: ['autodocs'],
|
|
12
|
-
parameters: {
|
|
13
|
-
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
14
|
-
layout: 'fullscreen',
|
|
15
|
-
},
|
|
16
|
-
args: {
|
|
17
|
-
onLogin: fn(),
|
|
18
|
-
onLogout: fn(),
|
|
19
|
-
onCreateAccount: fn(),
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<Story name="Logged In" args={{ user: { name: 'Jane Doe' } }} />
|
|
25
|
-
|
|
26
|
-
<Story name="Logged Out" />
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import './page.css';
|
|
3
|
-
import Header from './Header.svelte';
|
|
4
|
-
|
|
5
|
-
let user = $state<{ name: string }>();
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<article>
|
|
9
|
-
<Header
|
|
10
|
-
{user}
|
|
11
|
-
onLogin={() => (user = { name: 'Jane Doe' })}
|
|
12
|
-
onLogout={() => (user = undefined)}
|
|
13
|
-
onCreateAccount={() => (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>
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/sveltekit';
|
|
2
|
-
|
|
3
|
-
import Button from './Button.svelte';
|
|
4
|
-
|
|
5
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
6
|
-
const meta = {
|
|
7
|
-
title: 'Example/Button',
|
|
8
|
-
component: Button,
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
argTypes: {
|
|
11
|
-
backgroundColor: { control: 'color' },
|
|
12
|
-
size: {
|
|
13
|
-
control: { type: 'select' },
|
|
14
|
-
options: ['small', 'medium', 'large'],
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
} satisfies Meta<Button>;
|
|
18
|
-
|
|
19
|
-
export default meta;
|
|
20
|
-
type Story = StoryObj<typeof meta>;
|
|
21
|
-
|
|
22
|
-
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
23
|
-
export const Primary: Story = {
|
|
24
|
-
args: {
|
|
25
|
-
primary: true,
|
|
26
|
-
label: 'Button',
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const Secondary: Story = {
|
|
31
|
-
args: {
|
|
32
|
-
label: 'Button',
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const Large: Story = {
|
|
37
|
-
args: {
|
|
38
|
-
size: 'large',
|
|
39
|
-
label: 'Button',
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const Small: Story = {
|
|
44
|
-
args: {
|
|
45
|
-
size: 'small',
|
|
46
|
-
label: 'Button',
|
|
47
|
-
},
|
|
48
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import './button.css';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Is this the principal call to action on the page?
|
|
6
|
-
*/
|
|
7
|
-
export let primary = false;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* What background color to use
|
|
11
|
-
*/
|
|
12
|
-
export let backgroundColor: string | undefined = undefined;
|
|
13
|
-
/**
|
|
14
|
-
* How large should the button be?
|
|
15
|
-
*/
|
|
16
|
-
export let size: 'small' | 'medium' | 'large' = 'medium';
|
|
17
|
-
/**
|
|
18
|
-
* Button contents
|
|
19
|
-
*/
|
|
20
|
-
export let label: string = '';
|
|
21
|
-
|
|
22
|
-
$: mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
23
|
-
|
|
24
|
-
$: style = backgroundColor ? `background-color: ${backgroundColor}` : '';
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<button
|
|
28
|
-
type="button"
|
|
29
|
-
class={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
|
30
|
-
{style}
|
|
31
|
-
on:click
|
|
32
|
-
>
|
|
33
|
-
{label}
|
|
34
|
-
</button>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/sveltekit';
|
|
2
|
-
|
|
3
|
-
import Header from './Header.svelte';
|
|
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/writing-docs/autodocs
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
parameters: {
|
|
11
|
-
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
12
|
-
layout: 'fullscreen',
|
|
13
|
-
},
|
|
14
|
-
} satisfies Meta<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 = {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import './header.css';
|
|
3
|
-
import Button from './Button.svelte';
|
|
4
|
-
|
|
5
|
-
import { createEventDispatcher } from 'svelte';
|
|
6
|
-
|
|
7
|
-
export let user: { name: string } | null = null;
|
|
8
|
-
|
|
9
|
-
const dispatch = createEventDispatcher();
|
|
10
|
-
|
|
11
|
-
function onLogin(event: MouseEvent) {
|
|
12
|
-
dispatch('login', event);
|
|
13
|
-
}
|
|
14
|
-
function onLogout(event: MouseEvent) {
|
|
15
|
-
dispatch('logout', event);
|
|
16
|
-
}
|
|
17
|
-
function onCreateAccount(event: MouseEvent) {
|
|
18
|
-
dispatch('createAccount', event);
|
|
19
|
-
}
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
<header>
|
|
23
|
-
<div class="storybook-header">
|
|
24
|
-
<div>
|
|
25
|
-
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
|
26
|
-
<g fill="none" fill-rule="evenodd">
|
|
27
|
-
<path
|
|
28
|
-
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
|
|
29
|
-
fill="#FFF"
|
|
30
|
-
/>
|
|
31
|
-
<path
|
|
32
|
-
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
|
|
33
|
-
fill="#555AB9"
|
|
34
|
-
/>
|
|
35
|
-
<path d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z" fill="#91BAF8" />
|
|
36
|
-
</g>
|
|
37
|
-
</svg>
|
|
38
|
-
<h1>Acme</h1>
|
|
39
|
-
</div>
|
|
40
|
-
<div>
|
|
41
|
-
{#if user}
|
|
42
|
-
<span class="welcome">
|
|
43
|
-
Welcome, <b>{user.name}</b>!
|
|
44
|
-
</span>
|
|
45
|
-
<Button size="small" on:click={onLogout} label="Log out" />
|
|
46
|
-
{:else}
|
|
47
|
-
<Button size="small" on:click={onLogin} label="Log in" />
|
|
48
|
-
<Button primary size="small" on:click={onCreateAccount} label="Sign up" />
|
|
49
|
-
{/if}
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
</header>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/sveltekit';
|
|
2
|
-
import { expect, userEvent, waitFor, within } from '@storybook/test';
|
|
3
|
-
|
|
4
|
-
import Page from './Page.svelte';
|
|
5
|
-
|
|
6
|
-
const meta = {
|
|
7
|
-
title: 'Example/Page',
|
|
8
|
-
component: Page,
|
|
9
|
-
parameters: {
|
|
10
|
-
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
11
|
-
layout: 'fullscreen',
|
|
12
|
-
},
|
|
13
|
-
} satisfies Meta<Page>;
|
|
14
|
-
|
|
15
|
-
export default meta;
|
|
16
|
-
type Story = StoryObj<typeof meta>;
|
|
17
|
-
|
|
18
|
-
export const LoggedOut: Story = {};
|
|
19
|
-
|
|
20
|
-
// More on component testing: https://storybook.js.org/docs/writing-tests/component-testing
|
|
21
|
-
export const LoggedIn: Story = {
|
|
22
|
-
play: async ({ canvasElement }) => {
|
|
23
|
-
const canvas = within(canvasElement);
|
|
24
|
-
const loginButton = canvas.getByRole('button', { name: /Log in/i });
|
|
25
|
-
await expect(loginButton).toBeInTheDocument();
|
|
26
|
-
await userEvent.click(loginButton);
|
|
27
|
-
await waitFor(() => expect(loginButton).not.toBeInTheDocument());
|
|
28
|
-
|
|
29
|
-
const logoutButton = canvas.getByRole('button', { name: /Log out/i });
|
|
30
|
-
await expect(logoutButton).toBeInTheDocument();
|
|
31
|
-
},
|
|
32
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
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>
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/**
|
|
3
|
-
* @typedef {Object} MyObject
|
|
4
|
-
* @property {string} foo
|
|
5
|
-
* @property {number} bar
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @typedef {Object} MyProps
|
|
10
|
-
* @property {boolean=} boolean Boolean
|
|
11
|
-
* @property {string=} string String
|
|
12
|
-
* @property {string} stringRequired String (required)
|
|
13
|
-
* @property {number=} number Number
|
|
14
|
-
* @property {true=} trueLiteral True literal
|
|
15
|
-
* @property {symbol=} symbol Symbol
|
|
16
|
-
* @property {null=} nullValue Null
|
|
17
|
-
* @property {undefined=} undefinedValue Undefined
|
|
18
|
-
* @property {any=} any Any
|
|
19
|
-
* @property {import("./types").LiteralStrings=} unionLiteralStrings Union of literal strings
|
|
20
|
-
* @property {import("./types").LiteralNumbers=} unionLiteralNumbers Union of literal numbers
|
|
21
|
-
* @property {MyObject=} object Object
|
|
22
|
-
* @property {{ foo: string, bar: number }=} inlineObject Inline object
|
|
23
|
-
* @property {Record<string, number> =} record Record
|
|
24
|
-
* @property {Date=} date Date
|
|
25
|
-
* @property {number | string =} unionTypes Union of types
|
|
26
|
-
* @property {{ a: number } & { b: string } =} intersection Intersection of types
|
|
27
|
-
* @property {import("svelte").Snippet} children Snippet contents
|
|
28
|
-
* @property {(event: MouseEvent) => number =} func Event callback function
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/** @type {MyProps} */
|
|
32
|
-
let {
|
|
33
|
-
boolean = true,
|
|
34
|
-
string = 'default',
|
|
35
|
-
stringRequired,
|
|
36
|
-
number = 123,
|
|
37
|
-
trueLiteral = undefined,
|
|
38
|
-
symbol = undefined,
|
|
39
|
-
nullValue = null,
|
|
40
|
-
undefinedValue = undefined,
|
|
41
|
-
any = undefined,
|
|
42
|
-
unionLiteralStrings = 'apple',
|
|
43
|
-
unionLiteralNumbers = 1000,
|
|
44
|
-
object = undefined,
|
|
45
|
-
inlineObject = undefined,
|
|
46
|
-
record = { a: 1, b: 2 },
|
|
47
|
-
date = new Date('20 Jan 1983'),
|
|
48
|
-
unionTypes = 123,
|
|
49
|
-
intersection = undefined,
|
|
50
|
-
children,
|
|
51
|
-
func = () => 10,
|
|
52
|
-
} = $props();
|
|
53
|
-
</script>
|
|
54
|
-
|
|
55
|
-
<div>Docs: JSDoc + Runes</div>
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
import type { LiteralNumbers, LiteralStrings } from './types';
|
|
4
|
-
import { MyEnum } from './types';
|
|
5
|
-
|
|
6
|
-
type MyObject = {
|
|
7
|
-
foo: string;
|
|
8
|
-
bar: number;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let {
|
|
12
|
-
boolean = true,
|
|
13
|
-
string = 'default',
|
|
14
|
-
stringRequired,
|
|
15
|
-
number = 123,
|
|
16
|
-
nullValue = null,
|
|
17
|
-
arrayOfNumbers = [1, 20, 300],
|
|
18
|
-
enumValue = MyEnum.FOO,
|
|
19
|
-
record = { a: 1, b: 2 },
|
|
20
|
-
date = new Date('20 Jan 1983'),
|
|
21
|
-
unionTypes = 123,
|
|
22
|
-
func = () => 10,
|
|
23
|
-
}: {
|
|
24
|
-
/**
|
|
25
|
-
* Boolean
|
|
26
|
-
*/
|
|
27
|
-
boolean?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* String
|
|
30
|
-
*/
|
|
31
|
-
string?: string;
|
|
32
|
-
/**
|
|
33
|
-
* String (required)
|
|
34
|
-
*/
|
|
35
|
-
stringRequired: string;
|
|
36
|
-
/**
|
|
37
|
-
* Number
|
|
38
|
-
*/
|
|
39
|
-
number?: number;
|
|
40
|
-
/**
|
|
41
|
-
* True literal
|
|
42
|
-
*/
|
|
43
|
-
trueLiteral?: true;
|
|
44
|
-
/**
|
|
45
|
-
* Symbol
|
|
46
|
-
*/
|
|
47
|
-
symbol?: symbol;
|
|
48
|
-
/**
|
|
49
|
-
* Null
|
|
50
|
-
*/
|
|
51
|
-
nullValue?: null;
|
|
52
|
-
/**
|
|
53
|
-
* Undefined
|
|
54
|
-
*/
|
|
55
|
-
undefinedValue?: undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Any
|
|
58
|
-
*/
|
|
59
|
-
any?: any;
|
|
60
|
-
/**
|
|
61
|
-
* Array of numbers
|
|
62
|
-
*/
|
|
63
|
-
arrayOfNumbers?: number[];
|
|
64
|
-
/**
|
|
65
|
-
* Enum
|
|
66
|
-
*/
|
|
67
|
-
enumValue?: MyEnum;
|
|
68
|
-
/**
|
|
69
|
-
* Union of literal strings
|
|
70
|
-
*/
|
|
71
|
-
unionLiteralStrings?: LiteralStrings;
|
|
72
|
-
/**
|
|
73
|
-
* Union of literal numbers
|
|
74
|
-
*/
|
|
75
|
-
unionLiteralNumbers?: LiteralNumbers;
|
|
76
|
-
/**
|
|
77
|
-
* Object
|
|
78
|
-
*/
|
|
79
|
-
object?: MyObject;
|
|
80
|
-
/**
|
|
81
|
-
* Inline object
|
|
82
|
-
*/
|
|
83
|
-
inlineObject?: {
|
|
84
|
-
foo: string;
|
|
85
|
-
bar: number;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Record
|
|
89
|
-
*/
|
|
90
|
-
record?: Record<string, number>;
|
|
91
|
-
/**
|
|
92
|
-
* Date
|
|
93
|
-
*/
|
|
94
|
-
date?: Date;
|
|
95
|
-
/**
|
|
96
|
-
* Union of types
|
|
97
|
-
*/
|
|
98
|
-
unionTypes?: number | string;
|
|
99
|
-
/**
|
|
100
|
-
* Intersection of types
|
|
101
|
-
*/
|
|
102
|
-
intersection?: { a: number } & { b: string };
|
|
103
|
-
/**
|
|
104
|
-
* Snippet contents
|
|
105
|
-
*/
|
|
106
|
-
children: Snippet;
|
|
107
|
-
/**
|
|
108
|
-
* Event callback function
|
|
109
|
-
*/
|
|
110
|
-
func?: (event: MouseEvent) => number;
|
|
111
|
-
} = $props();
|
|
112
|
-
</script>
|
|
113
|
-
|
|
114
|
-
<div>Docs: TS + Runes (inline prop types)</div>
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
import type { LiteralNumbers, LiteralStrings } from './types';
|
|
4
|
-
import { MyEnum } from './types';
|
|
5
|
-
|
|
6
|
-
type MyObject = {
|
|
7
|
-
foo: string;
|
|
8
|
-
bar: number;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Boolean
|
|
13
|
-
*/
|
|
14
|
-
export let boolean: boolean = true;
|
|
15
|
-
/**
|
|
16
|
-
* String
|
|
17
|
-
*/
|
|
18
|
-
export let string: string = 'default';
|
|
19
|
-
/**
|
|
20
|
-
* String (required)
|
|
21
|
-
*/
|
|
22
|
-
export let stringRequired: string;
|
|
23
|
-
/**
|
|
24
|
-
* Number
|
|
25
|
-
*/
|
|
26
|
-
export let number: number = 123;
|
|
27
|
-
/**
|
|
28
|
-
* True literal
|
|
29
|
-
*/
|
|
30
|
-
export let trueLiteral: true | undefined = undefined;
|
|
31
|
-
/**
|
|
32
|
-
* Symbol
|
|
33
|
-
*/
|
|
34
|
-
export let symbol: symbol | undefined = undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Null
|
|
37
|
-
*/
|
|
38
|
-
export let nullValue: null = null;
|
|
39
|
-
/**
|
|
40
|
-
* Undefined
|
|
41
|
-
*/
|
|
42
|
-
export let undefinedValue: undefined = undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Any
|
|
45
|
-
*/
|
|
46
|
-
export let any: any = null;
|
|
47
|
-
/**
|
|
48
|
-
* Date
|
|
49
|
-
*/
|
|
50
|
-
export let date: Date = new Date('20 Jan 1983');
|
|
51
|
-
/**
|
|
52
|
-
* Array of numbers
|
|
53
|
-
*/
|
|
54
|
-
export let arrayOfNumbers: number[] = [1, 20, 300];
|
|
55
|
-
/**
|
|
56
|
-
* Enum
|
|
57
|
-
*/
|
|
58
|
-
export let enumValue: MyEnum = MyEnum.FOO;
|
|
59
|
-
/**
|
|
60
|
-
* Union of literal strings
|
|
61
|
-
*/
|
|
62
|
-
export let unionLiteralStrings: LiteralStrings = 'apple';
|
|
63
|
-
/**
|
|
64
|
-
* Union of literal numbers
|
|
65
|
-
*/
|
|
66
|
-
export let unionLiteralNumbers: LiteralNumbers = 1000;
|
|
67
|
-
/**
|
|
68
|
-
* Object
|
|
69
|
-
*/
|
|
70
|
-
export let object: MyObject | undefined = undefined;
|
|
71
|
-
/**
|
|
72
|
-
* Inline object
|
|
73
|
-
*/
|
|
74
|
-
export let inlineObject:
|
|
75
|
-
| {
|
|
76
|
-
foo: string;
|
|
77
|
-
bar: number;
|
|
78
|
-
}
|
|
79
|
-
| undefined = undefined;
|
|
80
|
-
/**
|
|
81
|
-
* Record
|
|
82
|
-
*/
|
|
83
|
-
export let record: Record<string, number> = { a: 1, b: 2 };
|
|
84
|
-
/**
|
|
85
|
-
* Union of types
|
|
86
|
-
*/
|
|
87
|
-
export let unionTypes: number | string = 123;
|
|
88
|
-
/**
|
|
89
|
-
* Intersection of types
|
|
90
|
-
*/
|
|
91
|
-
export let intersection: ({ a: number } & { b: string }) | undefined = undefined;
|
|
92
|
-
/**
|
|
93
|
-
* Snippet contents
|
|
94
|
-
*/
|
|
95
|
-
export let children: Snippet;
|
|
96
|
-
/**
|
|
97
|
-
* Event callback function
|
|
98
|
-
*/
|
|
99
|
-
export let func: (event: MouseEvent) => number = () => 10;
|
|
100
|
-
</script>
|
|
101
|
-
|
|
102
|
-
<div>Docs: TS (Non-runes mode)</div>
|