@storybook/sveltekit 9.0.0-alpha.12 → 9.0.0-alpha.14
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 +6 -6
- 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-skeleton-js → 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/Button.svelte +0 -36
- package/template/cli/js/Header.stories.js +0 -22
- package/template/cli/js/Header.svelte +0 -52
- package/template/cli/js/Page.stories.js +0 -28
- package/template/cli/js/Page.svelte +0 -70
- 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.stories.svelte +0 -26
- package/template/cli/svelte-5-js/Header.svelte +0 -47
- package/template/cli/svelte-5-js/Page.stories.svelte +0 -30
- package/template/cli/svelte-5-js/Page.svelte +0 -70
- package/template/cli/svelte-5-ts-3-8/Button.stories.svelte +0 -31
- package/template/cli/svelte-5-ts-3-8/Button.svelte +0 -29
- package/template/cli/svelte-5-ts-3-8/Header.stories.svelte +0 -26
- 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-3-8/Page.svelte +0 -70
- package/template/cli/svelte-5-ts-4-9/Button.stories.svelte +0 -31
- 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/Header.svelte +0 -45
- package/template/cli/svelte-5-ts-4-9/Page.stories.svelte +0 -30
- 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/navigation.stories.js +0 -121
- 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/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/{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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/sveltekit",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.14",
|
|
4
4
|
"description": "Storybook for SvelteKit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"prep": "jiti ../../../scripts/prepare/bundle.ts"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@storybook/builder-vite": "9.0.0-alpha.
|
|
69
|
-
"@storybook/svelte": "9.0.0-alpha.
|
|
70
|
-
"@storybook/svelte-vite": "9.0.0-alpha.
|
|
68
|
+
"@storybook/builder-vite": "9.0.0-alpha.14",
|
|
69
|
+
"@storybook/svelte": "9.0.0-alpha.14",
|
|
70
|
+
"@storybook/svelte-vite": "9.0.0-alpha.14"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/node": "^22.0.0",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"vite": "5.1.6"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"storybook": "^9.0.0-alpha.
|
|
79
|
-
"svelte": "^
|
|
78
|
+
"storybook": "^9.0.0-alpha.14",
|
|
79
|
+
"svelte": "^5.0.0",
|
|
80
80
|
"vite": "^5.0.0 || ^6.0.0"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|
|
@@ -3,9 +3,8 @@ import { expect, fn, within } from 'storybook/test';
|
|
|
3
3
|
import Forms from './Forms.svelte';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/forms',
|
|
6
|
+
title: 'stories/frameworks/sveltekit/modules/forms',
|
|
7
7
|
component: Forms,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
8
|
};
|
|
10
9
|
|
|
11
10
|
const enhance = fn();
|
|
@@ -3,9 +3,8 @@ import { expect, fn, within } from 'storybook/test';
|
|
|
3
3
|
import Hrefs from './Hrefs.svelte';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/hrefs',
|
|
6
|
+
title: 'stories/frameworks/sveltekit/modules/hrefs',
|
|
7
7
|
component: Hrefs,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
8
|
};
|
|
10
9
|
|
|
11
10
|
export const DefaultActions = {
|
|
@@ -3,9 +3,8 @@ import { expect, fn, within } from 'storybook/test';
|
|
|
3
3
|
import Navigation from './Navigation.svelte';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
title: 'stories/sveltekit/modules/navigation',
|
|
6
|
+
title: 'stories/frameworks/sveltekit/modules/navigation',
|
|
7
7
|
component: Navigation,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
8
|
};
|
|
10
9
|
|
|
11
10
|
const goto = fn();
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import Button from './Button.svelte';
|
|
2
|
-
|
|
3
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
4
|
-
export default {
|
|
5
|
-
title: 'Example/Button',
|
|
6
|
-
component: Button,
|
|
7
|
-
tags: ['autodocs'],
|
|
8
|
-
argTypes: {
|
|
9
|
-
backgroundColor: { control: 'color' },
|
|
10
|
-
size: {
|
|
11
|
-
control: { type: 'select' },
|
|
12
|
-
options: ['small', 'medium', 'large'],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
18
|
-
export const Primary = {
|
|
19
|
-
args: {
|
|
20
|
-
primary: true,
|
|
21
|
-
label: 'Button',
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const Secondary = {
|
|
26
|
-
args: {
|
|
27
|
-
label: 'Button',
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const Large = {
|
|
32
|
-
args: {
|
|
33
|
-
size: 'large',
|
|
34
|
-
label: 'Button',
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const Small = {
|
|
39
|
-
args: {
|
|
40
|
-
size: 'small',
|
|
41
|
-
label: 'Button',
|
|
42
|
-
},
|
|
43
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
<script>
|
|
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
|
-
* @type {string} What background color to use
|
|
11
|
-
*/
|
|
12
|
-
export let backgroundColor = undefined;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @type {'small' | 'medium' | 'large'} How large should the button be?
|
|
16
|
-
*/
|
|
17
|
-
export let size = 'medium';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @type {string} Button contents
|
|
21
|
-
*/
|
|
22
|
-
export let label;
|
|
23
|
-
|
|
24
|
-
$: mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
25
|
-
|
|
26
|
-
$: style = backgroundColor ? `background-color: ${backgroundColor}` : '';
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<button
|
|
30
|
-
type="button"
|
|
31
|
-
class={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
|
32
|
-
{style}
|
|
33
|
-
on:click
|
|
34
|
-
>
|
|
35
|
-
{label}
|
|
36
|
-
</button>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import Header from './Header.svelte';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'Example/Header',
|
|
5
|
-
component: Header,
|
|
6
|
-
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
7
|
-
tags: ['autodocs'],
|
|
8
|
-
parameters: {
|
|
9
|
-
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
10
|
-
layout: 'fullscreen',
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const LoggedIn = {
|
|
15
|
-
args: {
|
|
16
|
-
user: {
|
|
17
|
-
name: 'Jane Doe',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const LoggedOut = {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import './header.css';
|
|
3
|
-
import Button from './Button.svelte';
|
|
4
|
-
|
|
5
|
-
import { createEventDispatcher } from 'svelte';
|
|
6
|
-
|
|
7
|
-
export let user = null;
|
|
8
|
-
|
|
9
|
-
const dispatch = createEventDispatcher();
|
|
10
|
-
|
|
11
|
-
function onLogin(event) {
|
|
12
|
-
dispatch('login', event);
|
|
13
|
-
}
|
|
14
|
-
function onLogout(event) {
|
|
15
|
-
dispatch('logout', event);
|
|
16
|
-
}
|
|
17
|
-
function onCreateAccount(event) {
|
|
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,28 +0,0 @@
|
|
|
1
|
-
import { expect, userEvent, waitFor, within } from '@storybook/test';
|
|
2
|
-
|
|
3
|
-
import Page from './Page.svelte';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Example/Page',
|
|
7
|
-
component: Page,
|
|
8
|
-
parameters: {
|
|
9
|
-
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
10
|
-
layout: 'fullscreen',
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const LoggedOut = {};
|
|
15
|
-
|
|
16
|
-
// More on component testing: https://storybook.js.org/docs/writing-tests/component-testing
|
|
17
|
-
export const LoggedIn = {
|
|
18
|
-
play: async ({ canvasElement }) => {
|
|
19
|
-
const canvas = within(canvasElement);
|
|
20
|
-
const loginButton = canvas.getByRole('button', { name: /Log in/i });
|
|
21
|
-
await expect(loginButton).toBeInTheDocument();
|
|
22
|
-
await userEvent.click(loginButton);
|
|
23
|
-
await waitFor(() => expect(loginButton).not.toBeInTheDocument());
|
|
24
|
-
|
|
25
|
-
const logoutButton = canvas.getByRole('button', { name: /Log out/i });
|
|
26
|
-
await expect(logoutButton).toBeInTheDocument();
|
|
27
|
-
},
|
|
28
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import './page.css';
|
|
3
|
-
import Header from './Header.svelte';
|
|
4
|
-
|
|
5
|
-
let user = 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,31 +0,0 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import Button from './Button.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/Button',
|
|
9
|
-
component: Button,
|
|
10
|
-
tags: ['autodocs'],
|
|
11
|
-
argTypes: {
|
|
12
|
-
backgroundColor: { control: 'color' },
|
|
13
|
-
size: {
|
|
14
|
-
control: { type: 'select' },
|
|
15
|
-
options: ['small', 'medium', 'large'],
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
args: {
|
|
19
|
-
onClick: fn(),
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<!-- More on writing stories with args: https://storybook.js.org/docs/writing-stories/args -->
|
|
25
|
-
<Story name="Primary" args={{ primary: true, label: 'Button' }} />
|
|
26
|
-
|
|
27
|
-
<Story name="Secondary" args={{ label: 'Button' }} />
|
|
28
|
-
|
|
29
|
-
<Story name="Large" args={{ size: 'large', label: 'Button' }} />
|
|
30
|
-
|
|
31
|
-
<Story name="Small" args={{ size: 'small', label: 'Button' }} />
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import './button.css';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {Object} Props
|
|
6
|
-
* @property {boolean} [primary] Is this the principal call to action on the page?
|
|
7
|
-
* @property {string} [backgroundColor] What background color to use
|
|
8
|
-
* @property {'small' | 'medium' | 'large'} [size] How large should the button be?
|
|
9
|
-
* @property {string} label Button contents
|
|
10
|
-
* @property {() => void} [onClick] The onclick event handler
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/** @type {Props} */
|
|
14
|
-
const { primary = false, backgroundColor, size = 'medium', label, onClick } = $props();
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<button
|
|
18
|
-
type="button"
|
|
19
|
-
class={['storybook-button', `storybook-button--${size}`].join(' ')}
|
|
20
|
-
class:storybook-button--primary={primary}
|
|
21
|
-
class:storybook-button--secondary={!primary}
|
|
22
|
-
style:background-color={backgroundColor}
|
|
23
|
-
onclick={onClick}
|
|
24
|
-
>
|
|
25
|
-
{label}
|
|
26
|
-
</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,47 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import './header.css';
|
|
3
|
-
import Button from './Button.svelte';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {Object} Props
|
|
7
|
-
* @property {{name: string}} [user] The user object
|
|
8
|
-
* @property {() => void} [onLogin] The login event handler
|
|
9
|
-
* @property {() => void} [onLogout] The logout event handler
|
|
10
|
-
* @property {() => void} [onCreateAccount] The account creation event handler
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/** @type {Props} */
|
|
14
|
-
const { user, onLogin, onLogout, onCreateAccount } = $props();
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<header>
|
|
18
|
-
<div class="storybook-header">
|
|
19
|
-
<div>
|
|
20
|
-
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
|
21
|
-
<g fill="none" fill-rule="evenodd">
|
|
22
|
-
<path
|
|
23
|
-
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
|
|
24
|
-
fill="#FFF"
|
|
25
|
-
/>
|
|
26
|
-
<path
|
|
27
|
-
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
|
|
28
|
-
fill="#555AB9"
|
|
29
|
-
/>
|
|
30
|
-
<path d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z" fill="#91BAF8" />
|
|
31
|
-
</g>
|
|
32
|
-
</svg>
|
|
33
|
-
<h1>Acme</h1>
|
|
34
|
-
</div>
|
|
35
|
-
<div>
|
|
36
|
-
{#if user}
|
|
37
|
-
<span class="welcome">
|
|
38
|
-
Welcome, <b>{user.name}</b>!
|
|
39
|
-
</span>
|
|
40
|
-
<Button size="small" onClick={onLogout} label="Log out" />
|
|
41
|
-
{:else}
|
|
42
|
-
<Button size="small" onClick={onLogin} label="Log in" />
|
|
43
|
-
<Button primary size="small" onClick={onCreateAccount} label="Sign up" />
|
|
44
|
-
{/if}
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
</header>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { expect, userEvent, waitFor, within } from '@storybook/test';
|
|
4
|
-
import Page from './Page.svelte';
|
|
5
|
-
import { fn } from 'storybook/test';
|
|
6
|
-
|
|
7
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
-
const { Story } = defineMeta({
|
|
9
|
-
title: 'Example/Page',
|
|
10
|
-
component: Page,
|
|
11
|
-
parameters: {
|
|
12
|
-
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
13
|
-
layout: 'fullscreen',
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<Story name="Logged In" play={async ({ canvasElement }) => {
|
|
19
|
-
const canvas = within(canvasElement);
|
|
20
|
-
const loginButton = canvas.getByRole('button', { name: /Log in/i });
|
|
21
|
-
await expect(loginButton).toBeInTheDocument();
|
|
22
|
-
await userEvent.click(loginButton);
|
|
23
|
-
await waitFor(() => expect(loginButton).not.toBeInTheDocument());
|
|
24
|
-
|
|
25
|
-
const logoutButton = canvas.getByRole('button', { name: /Log out/i });
|
|
26
|
-
await expect(logoutButton).toBeInTheDocument();
|
|
27
|
-
}}
|
|
28
|
-
/>
|
|
29
|
-
|
|
30
|
-
<Story name="Logged Out" />
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import './page.css';
|
|
3
|
-
import Header from './Header.svelte';
|
|
4
|
-
|
|
5
|
-
let user = $state(null);
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<article>
|
|
9
|
-
<Header
|
|
10
|
-
{user}
|
|
11
|
-
onLogin={() => (user = { name: 'Jane Doe' })}
|
|
12
|
-
onLogout={() => (user = null)}
|
|
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,31 +0,0 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import Button from './Button.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/Button',
|
|
9
|
-
component: Button,
|
|
10
|
-
tags: ['autodocs'],
|
|
11
|
-
argTypes: {
|
|
12
|
-
backgroundColor: { control: 'color' },
|
|
13
|
-
size: {
|
|
14
|
-
control: { type: 'select' },
|
|
15
|
-
options: ['small', 'medium', 'large'],
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
args: {
|
|
19
|
-
onClick: fn(),
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<!-- More on writing stories with args: https://storybook.js.org/docs/writing-stories/args -->
|
|
25
|
-
<Story name="Primary" args={{ primary: true, label: 'Button' }} />
|
|
26
|
-
|
|
27
|
-
<Story name="Secondary" args={{ label: 'Button' }} />
|
|
28
|
-
|
|
29
|
-
<Story name="Large" args={{ size: 'large', label: 'Button' }} />
|
|
30
|
-
|
|
31
|
-
<Story name="Small" args={{ size: 'small', label: 'Button' }} />
|
|
@@ -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>
|