@storybook/svelte 9.0.0-alpha.9 → 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.
Files changed (49) hide show
  1. package/dist/chunk-2IXN2SLZ.mjs +11 -0
  2. package/dist/components/AddStorybookIdDecorator.svelte +3 -3
  3. package/dist/components/DecoratorHandler.svelte +20 -0
  4. package/dist/components/PreviewRender.svelte +14 -41
  5. package/dist/{createSvelte5Props.svelte.js → createReactiveProps.svelte.js} +1 -1
  6. package/dist/entry-preview-docs.js +1 -1
  7. package/dist/entry-preview-docs.mjs +3 -3
  8. package/dist/entry-preview.d.ts +1 -1
  9. package/dist/entry-preview.js +1 -1
  10. package/dist/entry-preview.mjs +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/index.mjs +3 -3
  13. package/package.json +8 -9
  14. package/template/cli/{svelte-5-ts-4-9 → js}/Button.stories.svelte +1 -1
  15. package/template/cli/js/Button.svelte +11 -20
  16. package/template/cli/js/Header.svelte +12 -17
  17. package/template/cli/js/Page.svelte +4 -4
  18. package/template/cli/{svelte-5-js → ts}/Button.stories.svelte +1 -1
  19. package/template/cli/{svelte-5-ts-3-8 → ts}/Button.svelte +8 -7
  20. package/template/cli/{svelte-5-ts-4-9 → ts}/Header.svelte +3 -3
  21. package/template/stories/args.stories.js +21 -10
  22. package/template/stories/{slot-decorators.stories.js → decorators.stories.js} +21 -8
  23. package/dist/chunk-XMMNDRKT.mjs +0 -12
  24. package/dist/components/SlotDecorator.svelte +0 -50
  25. package/template/cli/js/Button.stories.js +0 -43
  26. package/template/cli/js/Header.stories.js +0 -22
  27. package/template/cli/js/Page.stories.js +0 -28
  28. package/template/cli/svelte-5-js/Button.svelte +0 -26
  29. package/template/cli/svelte-5-js/Header.svelte +0 -47
  30. package/template/cli/svelte-5-js/Page.svelte +0 -70
  31. package/template/cli/svelte-5-ts-3-8/Button.stories.svelte +0 -31
  32. package/template/cli/svelte-5-ts-3-8/Header.svelte +0 -45
  33. package/template/cli/svelte-5-ts-4-9/Button.svelte +0 -29
  34. package/template/cli/svelte-5-ts-4-9/Header.stories.svelte +0 -26
  35. package/template/cli/svelte-5-ts-4-9/Page.stories.svelte +0 -30
  36. package/template/cli/svelte-5-ts-4-9/Page.svelte +0 -70
  37. package/template/cli/ts-4-9/Button.stories.ts +0 -48
  38. package/template/cli/ts-4-9/Button.svelte +0 -34
  39. package/template/cli/ts-4-9/Header.stories.ts +0 -27
  40. package/template/cli/ts-4-9/Header.svelte +0 -52
  41. package/template/cli/ts-4-9/Page.stories.ts +0 -33
  42. package/template/cli/ts-4-9/Page.svelte +0 -70
  43. package/template/stories/decorators-runs-once.stories.js +0 -16
  44. package/template/stories/docs-jsdoc.stories.js +0 -9
  45. /package/template/cli/{svelte-5-js → js}/Header.stories.svelte +0 -0
  46. /package/template/cli/{svelte-5-js → js}/Page.stories.svelte +0 -0
  47. /package/template/cli/{svelte-5-ts-3-8 → ts}/Header.stories.svelte +0 -0
  48. /package/template/cli/{svelte-5-ts-3-8 → ts}/Page.stories.svelte +0 -0
  49. /package/template/cli/{svelte-5-ts-3-8 → ts}/Page.svelte +0 -0
@@ -1,50 +0,0 @@
1
- <script>
2
- import { onMount } from 'svelte';
3
- import { VERSION } from 'svelte/compiler';
4
-
5
- export let decorator = undefined;
6
- export let Component;
7
- export let props = {};
8
- export let on = undefined;
9
- export let argTypes = undefined;
10
-
11
- let instance;
12
- let decoratorInstance;
13
-
14
- const svelteVersion = VERSION[0];
15
-
16
- /*
17
- Svelte Docgen will create argTypes for events with the name 'event_eventName'
18
- The Actions addon will convert these to args because they are type: 'action'
19
- We need to filter these args out so they are not passed to the component
20
- */
21
- let propsWithoutDocgenEvents;
22
- $: propsWithoutDocgenEvents = Object.fromEntries(
23
- Object.entries(props).filter(([key]) => !key.startsWith('event_'))
24
- );
25
-
26
- if (argTypes && svelteVersion < 5) {
27
- const eventsFromArgTypes = Object.fromEntries(
28
- Object.entries(argTypes)
29
- .filter(([key, value]) => value.action && props[key] != null)
30
- .map(([key, value]) => [value.action, props[key]])
31
- );
32
- // Attach Svelte event listeners in Svelte v4
33
- // In Svelte v5 this is not possible anymore as instances are no longer classes with $on() properties, so it will be a no-op
34
- onMount(() => {
35
- Object.entries({ ...eventsFromArgTypes, ...on }).forEach(([eventName, eventCallback]) => {
36
- // instance can be undefined if a decorator doesn't have a <slot/>
37
- const inst = instance ?? decoratorInstance;
38
- inst?.$on?.(eventName, eventCallback);
39
- });
40
- });
41
- }
42
- </script>
43
-
44
- {#if decorator}
45
- <svelte:component this={decorator.Component} {...decorator.props} bind:this={decoratorInstance}>
46
- <svelte:component this={Component} {...propsWithoutDocgenEvents} bind:this={instance} />
47
- </svelte:component>
48
- {:else}
49
- <svelte:component this={Component} {...propsWithoutDocgenEvents} bind:this={instance} />
50
- {/if}
@@ -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,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,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,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,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,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,45 +0,0 @@
1
- <script lang="ts">
2
- import './header.css';
3
- import Button from './Button.svelte';
4
-
5
- interface Props {
6
- user?: { name: string };
7
- onLogin?: () => void;
8
- onLogout?: () => void;
9
- onCreateAccount?: () => void;
10
- }
11
-
12
- const { user, onLogin, onLogout, onCreateAccount }: Props = $props();
13
- </script>
14
-
15
- <header>
16
- <div class="storybook-header">
17
- <div>
18
- <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
19
- <g fill="none" fill-rule="evenodd">
20
- <path
21
- d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
22
- fill="#FFF"
23
- />
24
- <path
25
- d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
26
- fill="#555AB9"
27
- />
28
- <path d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z" fill="#91BAF8" />
29
- </g>
30
- </svg>
31
- <h1>Acme</h1>
32
- </div>
33
- <div>
34
- {#if user}
35
- <span class="welcome">
36
- Welcome, <b>{user.name}</b>!
37
- </span>
38
- <Button size="small" onClick={onLogout} label="Log out" />
39
- {:else}
40
- <Button size="small" onClick={onLogin} label="Log in" />
41
- <Button primary size="small" onClick={onCreateAccount} label="Sign up" />
42
- {/if}
43
- </div>
44
- </div>
45
- </header>
@@ -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,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 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,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/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 = {};