@storybook/svelte 9.0.0-alpha.13 → 9.0.0-alpha.15
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/chunk-2IXN2SLZ.mjs +11 -0
- package/dist/components/AddStorybookIdDecorator.svelte +3 -3
- package/dist/components/DecoratorHandler.svelte +20 -0
- package/dist/components/PreviewRender.svelte +14 -41
- package/dist/{createSvelte5Props.svelte.js → createReactiveProps.svelte.js} +1 -1
- package/dist/entry-preview-docs.js +1 -1
- package/dist/entry-preview-docs.mjs +3 -3
- package/dist/entry-preview.d.ts +1 -1
- package/dist/entry-preview.js +1 -1
- package/dist/entry-preview.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +3 -3
- package/package.json +6 -6
- package/template/cli/{svelte-5-ts-4-9 → 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/js/Page.svelte +4 -4
- package/template/cli/{svelte-5-js → ts-4-9}/Button.stories.svelte +1 -1
- package/template/cli/ts-4-9/Button.svelte +17 -21
- package/template/cli/ts-4-9/Header.svelte +10 -17
- package/template/cli/ts-4-9/Page.svelte +4 -4
- package/template/stories/args.stories.js +21 -10
- package/template/stories/{slot-decorators.stories.js → decorators.stories.js} +21 -8
- package/dist/chunk-XMMNDRKT.mjs +0 -12
- package/dist/components/SlotDecorator.svelte +0 -50
- 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.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/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.svelte +0 -45
- package/template/cli/svelte-5-ts-3-8/Page.svelte +0 -70
- 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/Header.stories.ts +0 -27
- package/template/cli/ts-4-9/Page.stories.ts +0 -33
- package/template/stories/decorators-runs-once.stories.js +0 -16
- package/template/stories/docs-jsdoc.stories.js +0 -9
- /package/template/cli/{svelte-5-js → js}/Header.stories.svelte +0 -0
- /package/template/cli/{svelte-5-js → js}/Page.stories.svelte +0 -0
- /package/template/cli/{svelte-5-ts-3-8 → ts-4-9}/Header.stories.svelte +0 -0
- /package/template/cli/{svelte-5-ts-3-8 → ts-4-9}/Page.stories.svelte +0 -0
|
@@ -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/svelte';
|
|
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,27 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/svelte';
|
|
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,33 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/svelte';
|
|
2
|
-
|
|
3
|
-
import { expect, userEvent, waitFor, within } from 'storybook/test';
|
|
4
|
-
|
|
5
|
-
import Page from './Page.svelte';
|
|
6
|
-
|
|
7
|
-
const meta = {
|
|
8
|
-
title: 'Example/Page',
|
|
9
|
-
component: Page,
|
|
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<Page>;
|
|
15
|
-
|
|
16
|
-
export default meta;
|
|
17
|
-
type Story = StoryObj<typeof meta>;
|
|
18
|
-
|
|
19
|
-
export const LoggedOut: Story = {};
|
|
20
|
-
|
|
21
|
-
// More on component testing: https://storybook.js.org/docs/writing-tests/component-testing
|
|
22
|
-
export const LoggedIn: Story = {
|
|
23
|
-
play: async ({ canvasElement }) => {
|
|
24
|
-
const canvas = within(canvasElement);
|
|
25
|
-
const loginButton = canvas.getByRole('button', { name: /Log in/i });
|
|
26
|
-
await expect(loginButton).toBeInTheDocument();
|
|
27
|
-
await userEvent.click(loginButton);
|
|
28
|
-
await waitFor(() => expect(loginButton).not.toBeInTheDocument());
|
|
29
|
-
|
|
30
|
-
const logoutButton = canvas.getByRole('button', { name: /Log out/i });
|
|
31
|
-
await expect(logoutButton).toBeInTheDocument();
|
|
32
|
-
},
|
|
33
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import ButtonJavaScript from './views/ButtonJavaScript.svelte';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
component: ButtonJavaScript,
|
|
5
|
-
args: {
|
|
6
|
-
primary: true,
|
|
7
|
-
},
|
|
8
|
-
decorators: [
|
|
9
|
-
(Story) => {
|
|
10
|
-
console.log('decorator called');
|
|
11
|
-
return Story();
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const Default = {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|