@storybook/svelte 9.0.0-alpha.9 → 9.0.0-beta.1
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 +8 -9
- 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}/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/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/Header.svelte +0 -45
- 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.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 -33
- package/template/cli/ts-4-9/Page.svelte +0 -70
- 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}/Header.stories.svelte +0 -0
- /package/template/cli/{svelte-5-ts-3-8 → ts}/Page.stories.svelte +0 -0
- /package/template/cli/{svelte-5-ts-3-8 → ts}/Page.svelte +0 -0
|
@@ -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,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,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,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
|
|
File without changes
|