@storybook/web-components-vite 9.0.0-alpha.1 → 9.0.0-alpha.3
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/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/node/index.d.ts +1 -0
- package/package.json +5 -4
- package/template/cli/.eslintrc.json +5 -0
- package/template/cli/js/Button.js +20 -0
- package/template/cli/js/Button.stories.js +46 -0
- package/template/cli/js/Header.js +45 -0
- package/template/cli/js/Header.stories.js +24 -0
- package/template/cli/js/Page.js +62 -0
- package/template/cli/js/Page.stories.js +20 -0
- package/template/cli/ts-4-9/Button.stories.ts +52 -0
- package/template/cli/ts-4-9/Button.ts +32 -0
- package/template/cli/ts-4-9/Header.stories.ts +31 -0
- package/template/cli/ts-4-9/Header.ts +56 -0
- package/template/cli/ts-4-9/Page.stories.ts +26 -0
- package/template/cli/ts-4-9/Page.ts +73 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var index_exports={};module.exports=__toCommonJS(index_exports);
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__reExport=(target,mod,secondTarget)=>(__copyProps(target,mod,"default"),secondTarget&&__copyProps(secondTarget,mod,"default"));var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var index_exports={};module.exports=__toCommonJS(index_exports);__reExport(index_exports,require("@storybook/web-components"),module.exports);0&&(module.exports={...require("@storybook/web-components")});
|
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
export * from '@storybook/web-components';
|
package/dist/node/index.d.ts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storybook/web-components-vite",
|
3
|
-
"version": "9.0.0-alpha.
|
3
|
+
"version": "9.0.0-alpha.3",
|
4
4
|
"description": "Storybook for web-components and Vite: Develop Web Components in isolation with Hot Reloading.",
|
5
5
|
"keywords": [
|
6
6
|
"storybook"
|
@@ -43,6 +43,7 @@
|
|
43
43
|
"types": "dist/index.d.ts",
|
44
44
|
"files": [
|
45
45
|
"dist/**/*",
|
46
|
+
"template/**/*",
|
46
47
|
"README.md",
|
47
48
|
"*.js",
|
48
49
|
"*.d.ts",
|
@@ -53,8 +54,8 @@
|
|
53
54
|
"prep": "jiti ../../../scripts/prepare/bundle.ts"
|
54
55
|
},
|
55
56
|
"dependencies": {
|
56
|
-
"@storybook/builder-vite": "9.0.0-alpha.
|
57
|
-
"@storybook/web-components": "9.0.0-alpha.
|
57
|
+
"@storybook/builder-vite": "9.0.0-alpha.3",
|
58
|
+
"@storybook/web-components": "9.0.0-alpha.3",
|
58
59
|
"magic-string": "^0.30.0"
|
59
60
|
},
|
60
61
|
"devDependencies": {
|
@@ -62,7 +63,7 @@
|
|
62
63
|
"typescript": "^5.7.3"
|
63
64
|
},
|
64
65
|
"peerDependencies": {
|
65
|
-
"storybook": "^9.0.0-alpha.
|
66
|
+
"storybook": "^9.0.0-alpha.3"
|
66
67
|
},
|
67
68
|
"engines": {
|
68
69
|
"node": ">=18.0.0"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { html } from 'lit';
|
2
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
3
|
+
|
4
|
+
import './button.css';
|
5
|
+
|
6
|
+
/** Primary UI component for user interaction */
|
7
|
+
export const Button = ({ primary, backgroundColor = null, size, label, onClick }) => {
|
8
|
+
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
9
|
+
|
10
|
+
return html`
|
11
|
+
<button
|
12
|
+
type="button"
|
13
|
+
class=${['storybook-button', `storybook-button--${size || 'medium'}`, mode].join(' ')}
|
14
|
+
style=${styleMap({ backgroundColor })}
|
15
|
+
@click=${onClick}
|
16
|
+
>
|
17
|
+
${label}
|
18
|
+
</button>
|
19
|
+
`;
|
20
|
+
};
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { fn } from 'storybook/test';
|
2
|
+
|
3
|
+
import { Button } from './Button';
|
4
|
+
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
6
|
+
export default {
|
7
|
+
title: 'Example/Button',
|
8
|
+
tags: ['autodocs'],
|
9
|
+
render: (args) => Button(args),
|
10
|
+
argTypes: {
|
11
|
+
backgroundColor: { control: 'color' },
|
12
|
+
size: {
|
13
|
+
control: { type: 'select' },
|
14
|
+
options: ['small', 'medium', 'large'],
|
15
|
+
},
|
16
|
+
},
|
17
|
+
args: { onClick: fn() },
|
18
|
+
};
|
19
|
+
|
20
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
21
|
+
export const Primary = {
|
22
|
+
args: {
|
23
|
+
primary: true,
|
24
|
+
label: 'Button',
|
25
|
+
},
|
26
|
+
};
|
27
|
+
|
28
|
+
export const Secondary = {
|
29
|
+
args: {
|
30
|
+
label: 'Button',
|
31
|
+
},
|
32
|
+
};
|
33
|
+
|
34
|
+
export const Large = {
|
35
|
+
args: {
|
36
|
+
size: 'large',
|
37
|
+
label: 'Button',
|
38
|
+
},
|
39
|
+
};
|
40
|
+
|
41
|
+
export const Small = {
|
42
|
+
args: {
|
43
|
+
size: 'small',
|
44
|
+
label: 'Button',
|
45
|
+
},
|
46
|
+
};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { html } from 'lit';
|
2
|
+
|
3
|
+
import { Button } from './Button';
|
4
|
+
import './header.css';
|
5
|
+
|
6
|
+
export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => html`
|
7
|
+
<header>
|
8
|
+
<div class="storybook-header">
|
9
|
+
<div>
|
10
|
+
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
11
|
+
<g fill="none" fillRule="evenodd">
|
12
|
+
<path
|
13
|
+
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
|
14
|
+
fill="#FFF"
|
15
|
+
/>
|
16
|
+
<path
|
17
|
+
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
|
18
|
+
fill="#555AB9"
|
19
|
+
/>
|
20
|
+
<path
|
21
|
+
d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
|
22
|
+
fill="#91BAF8"
|
23
|
+
/>
|
24
|
+
</g>
|
25
|
+
</svg>
|
26
|
+
<h1>Acme</h1>
|
27
|
+
</div>
|
28
|
+
<div>
|
29
|
+
${user
|
30
|
+
? Button({ size: 'small', onClick: onLogout, label: 'Log out' })
|
31
|
+
: html`${Button({
|
32
|
+
size: 'small',
|
33
|
+
onClick: onLogin,
|
34
|
+
label: 'Log in',
|
35
|
+
})}
|
36
|
+
${Button({
|
37
|
+
primary: true,
|
38
|
+
size: 'small',
|
39
|
+
onClick: onCreateAccount,
|
40
|
+
label: 'Sign up',
|
41
|
+
})}`}
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
</header>
|
45
|
+
`;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { fn } from 'storybook/test';
|
2
|
+
|
3
|
+
import { Header } from './Header';
|
4
|
+
|
5
|
+
export default {
|
6
|
+
title: 'Example/Header',
|
7
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/web-components/vue/writing-docs/autodocs
|
8
|
+
tags: ['autodocs'],
|
9
|
+
render: (args) => Header(args),
|
10
|
+
args: {
|
11
|
+
onLogin: fn(),
|
12
|
+
onLogout: fn(),
|
13
|
+
onCreateAccount: fn(),
|
14
|
+
},
|
15
|
+
};
|
16
|
+
export const LoggedIn = {
|
17
|
+
args: {
|
18
|
+
user: {
|
19
|
+
name: 'Jane Doe',
|
20
|
+
},
|
21
|
+
},
|
22
|
+
};
|
23
|
+
|
24
|
+
export const LoggedOut = {};
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import { html } from 'lit';
|
2
|
+
|
3
|
+
import { Header } from './Header';
|
4
|
+
import './page.css';
|
5
|
+
|
6
|
+
export const Page = ({ user, onLogin, onLogout, onCreateAccount }) => html`
|
7
|
+
<article>
|
8
|
+
${Header({
|
9
|
+
user,
|
10
|
+
onLogin,
|
11
|
+
onLogout,
|
12
|
+
onCreateAccount,
|
13
|
+
})}
|
14
|
+
|
15
|
+
<section class="storybook-page">
|
16
|
+
<h2>Pages in Storybook</h2>
|
17
|
+
<p>
|
18
|
+
We recommend building UIs with a
|
19
|
+
<a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
|
20
|
+
<strong>component-driven</strong> </a
|
21
|
+
>process starting with atomic components and ending with pages.
|
22
|
+
</p>
|
23
|
+
<p>
|
24
|
+
Render pages with mock data. This makes it easy to build and review page states without
|
25
|
+
needing to navigate to them in your app. Here are some handy patterns for managing page data
|
26
|
+
in Storybook:
|
27
|
+
</p>
|
28
|
+
<ul>
|
29
|
+
<li>
|
30
|
+
Use a higher-level connected component. Storybook helps you compose such data from the
|
31
|
+
"args" of child component stories
|
32
|
+
</li>
|
33
|
+
<li>
|
34
|
+
Assemble data in the page component from your services. You can mock these services out
|
35
|
+
using Storybook.
|
36
|
+
</li>
|
37
|
+
</ul>
|
38
|
+
<p>
|
39
|
+
Get a guided tutorial on component-driven development at
|
40
|
+
<a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
|
41
|
+
Storybook tutorials
|
42
|
+
</a>
|
43
|
+
. Read more in the
|
44
|
+
<a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer"> docs </a>
|
45
|
+
.
|
46
|
+
</p>
|
47
|
+
<div class="tip-wrapper">
|
48
|
+
<span class="tip">Tip</span> Adjust the width of the canvas with the
|
49
|
+
<svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
|
50
|
+
<g fill="none" fillRule="evenodd">
|
51
|
+
<path
|
52
|
+
d="M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0 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 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"
|
53
|
+
id="a"
|
54
|
+
fill="#999"
|
55
|
+
/>
|
56
|
+
</g>
|
57
|
+
</svg>
|
58
|
+
Viewports addon in the toolbar
|
59
|
+
</div>
|
60
|
+
</section>
|
61
|
+
</article>
|
62
|
+
`;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import * as HeaderStories from './Header.stories';
|
2
|
+
import { Page } from './Page';
|
3
|
+
|
4
|
+
export default {
|
5
|
+
title: 'Example/Page',
|
6
|
+
render: (args) => Page(args),
|
7
|
+
};
|
8
|
+
|
9
|
+
export const LoggedIn = {
|
10
|
+
args: {
|
11
|
+
// More on composing args: https://storybook.js.org/docs/writing-stories/args#args-composition
|
12
|
+
...HeaderStories.LoggedIn.args,
|
13
|
+
},
|
14
|
+
};
|
15
|
+
|
16
|
+
export const LoggedOut = {
|
17
|
+
args: {
|
18
|
+
...HeaderStories.LoggedOut.args,
|
19
|
+
},
|
20
|
+
};
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components-vite';
|
2
|
+
|
3
|
+
import { fn } from 'storybook/test';
|
4
|
+
|
5
|
+
import type { ButtonProps } from './Button';
|
6
|
+
import { Button } from './Button';
|
7
|
+
|
8
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
9
|
+
const meta = {
|
10
|
+
title: 'Example/Button',
|
11
|
+
tags: ['autodocs'],
|
12
|
+
render: (args) => Button(args),
|
13
|
+
argTypes: {
|
14
|
+
backgroundColor: { control: 'color' },
|
15
|
+
size: {
|
16
|
+
control: { type: 'select' },
|
17
|
+
options: ['small', 'medium', 'large'],
|
18
|
+
},
|
19
|
+
},
|
20
|
+
args: { onClick: fn() },
|
21
|
+
} satisfies Meta<ButtonProps>;
|
22
|
+
|
23
|
+
export default meta;
|
24
|
+
type Story = StoryObj<ButtonProps>;
|
25
|
+
|
26
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
27
|
+
export const Primary: Story = {
|
28
|
+
args: {
|
29
|
+
primary: true,
|
30
|
+
label: 'Button',
|
31
|
+
},
|
32
|
+
};
|
33
|
+
|
34
|
+
export const Secondary: Story = {
|
35
|
+
args: {
|
36
|
+
label: 'Button',
|
37
|
+
},
|
38
|
+
};
|
39
|
+
|
40
|
+
export const Large: Story = {
|
41
|
+
args: {
|
42
|
+
size: 'large',
|
43
|
+
label: 'Button',
|
44
|
+
},
|
45
|
+
};
|
46
|
+
|
47
|
+
export const Small: Story = {
|
48
|
+
args: {
|
49
|
+
size: 'small',
|
50
|
+
label: 'Button',
|
51
|
+
},
|
52
|
+
};
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { html } from 'lit';
|
2
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
3
|
+
|
4
|
+
import './button.css';
|
5
|
+
|
6
|
+
export interface ButtonProps {
|
7
|
+
/** Is this the principal call to action on the page? */
|
8
|
+
primary?: boolean;
|
9
|
+
/** What background color to use */
|
10
|
+
backgroundColor?: string;
|
11
|
+
/** How large should the button be? */
|
12
|
+
size?: 'small' | 'medium' | 'large';
|
13
|
+
/** Button contents */
|
14
|
+
label: string;
|
15
|
+
/** Optional click handler */
|
16
|
+
onClick?: () => void;
|
17
|
+
}
|
18
|
+
/** Primary UI component for user interaction */
|
19
|
+
export const Button = ({ primary, backgroundColor, size, label, onClick }: ButtonProps) => {
|
20
|
+
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
21
|
+
|
22
|
+
return html`
|
23
|
+
<button
|
24
|
+
type="button"
|
25
|
+
class=${['storybook-button', `storybook-button--${size || 'medium'}`, mode].join(' ')}
|
26
|
+
style=${styleMap({ backgroundColor })}
|
27
|
+
@click=${onClick}
|
28
|
+
>
|
29
|
+
${label}
|
30
|
+
</button>
|
31
|
+
`;
|
32
|
+
};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components-vite';
|
2
|
+
|
3
|
+
import { fn } from 'storybook/test';
|
4
|
+
|
5
|
+
import type { HeaderProps } from './Header';
|
6
|
+
import { Header } from './Header';
|
7
|
+
|
8
|
+
const meta = {
|
9
|
+
title: 'Example/Header',
|
10
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
11
|
+
tags: ['autodocs'],
|
12
|
+
render: (args: HeaderProps) => Header(args),
|
13
|
+
args: {
|
14
|
+
onLogin: fn(),
|
15
|
+
onLogout: fn(),
|
16
|
+
onCreateAccount: fn(),
|
17
|
+
},
|
18
|
+
} satisfies Meta<HeaderProps>;
|
19
|
+
|
20
|
+
export default meta;
|
21
|
+
type Story = StoryObj<HeaderProps>;
|
22
|
+
|
23
|
+
export const LoggedIn: Story = {
|
24
|
+
args: {
|
25
|
+
user: {
|
26
|
+
name: 'Jane Doe',
|
27
|
+
},
|
28
|
+
},
|
29
|
+
};
|
30
|
+
|
31
|
+
export const LoggedOut: Story = {};
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { html } from 'lit';
|
2
|
+
|
3
|
+
import { Button } from './Button';
|
4
|
+
import './header.css';
|
5
|
+
|
6
|
+
type User = {
|
7
|
+
name: string;
|
8
|
+
};
|
9
|
+
|
10
|
+
export interface HeaderProps {
|
11
|
+
user?: User;
|
12
|
+
onLogin?: () => void;
|
13
|
+
onLogout?: () => void;
|
14
|
+
onCreateAccount?: () => void;
|
15
|
+
}
|
16
|
+
|
17
|
+
export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => html`
|
18
|
+
<header>
|
19
|
+
<div class="storybook-header">
|
20
|
+
<div>
|
21
|
+
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
22
|
+
<g fill="none" fillRule="evenodd">
|
23
|
+
<path
|
24
|
+
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
|
25
|
+
fill="#FFF"
|
26
|
+
/>
|
27
|
+
<path
|
28
|
+
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
|
29
|
+
fill="#555AB9"
|
30
|
+
/>
|
31
|
+
<path
|
32
|
+
d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
|
33
|
+
fill="#91BAF8"
|
34
|
+
/>
|
35
|
+
</g>
|
36
|
+
</svg>
|
37
|
+
<h1>Acme</h1>
|
38
|
+
</div>
|
39
|
+
<div>
|
40
|
+
${user
|
41
|
+
? Button({ size: 'small', onClick: onLogout, label: 'Log out' })
|
42
|
+
: html`${Button({
|
43
|
+
size: 'small',
|
44
|
+
onClick: onLogin,
|
45
|
+
label: 'Log in',
|
46
|
+
})}
|
47
|
+
${Button({
|
48
|
+
primary: true,
|
49
|
+
size: 'small',
|
50
|
+
onClick: onCreateAccount,
|
51
|
+
label: 'Sign up',
|
52
|
+
})}`}
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
</header>
|
56
|
+
`;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components-vite';
|
2
|
+
|
3
|
+
import * as HeaderStories from './Header.stories';
|
4
|
+
import type { PageProps } from './Page';
|
5
|
+
import { Page } from './Page';
|
6
|
+
|
7
|
+
const meta = {
|
8
|
+
title: 'Example/Page',
|
9
|
+
render: (args: PageProps) => Page(args),
|
10
|
+
} satisfies Meta<PageProps>;
|
11
|
+
|
12
|
+
export default meta;
|
13
|
+
type Story = StoryObj<PageProps>;
|
14
|
+
|
15
|
+
export const LoggedIn: Story = {
|
16
|
+
args: {
|
17
|
+
// More on composing args: https://storybook.js.org/docs/writing-stories/args#args-composition
|
18
|
+
...HeaderStories.LoggedIn.args,
|
19
|
+
},
|
20
|
+
};
|
21
|
+
|
22
|
+
export const LoggedOut: Story = {
|
23
|
+
args: {
|
24
|
+
...HeaderStories.LoggedOut.args,
|
25
|
+
},
|
26
|
+
};
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { html } from 'lit';
|
2
|
+
|
3
|
+
import { Header } from './Header';
|
4
|
+
import './page.css';
|
5
|
+
|
6
|
+
type User = {
|
7
|
+
name: string;
|
8
|
+
};
|
9
|
+
|
10
|
+
export interface PageProps {
|
11
|
+
user?: User;
|
12
|
+
onLogin?: () => void;
|
13
|
+
onLogout?: () => void;
|
14
|
+
onCreateAccount?: () => void;
|
15
|
+
}
|
16
|
+
|
17
|
+
export const Page = ({ user, onLogin, onLogout, onCreateAccount }: PageProps) => html`
|
18
|
+
<article>
|
19
|
+
${Header({
|
20
|
+
user,
|
21
|
+
onLogin,
|
22
|
+
onLogout,
|
23
|
+
onCreateAccount,
|
24
|
+
})}
|
25
|
+
|
26
|
+
<section class="storybook-page">
|
27
|
+
<h2>Pages in Storybook</h2>
|
28
|
+
<p>
|
29
|
+
We recommend building UIs with a
|
30
|
+
<a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
|
31
|
+
<strong>component-driven</strong> </a
|
32
|
+
>process starting with atomic components and ending with pages.
|
33
|
+
</p>
|
34
|
+
<p>
|
35
|
+
Render pages with mock data. This makes it easy to build and review page states without
|
36
|
+
needing to navigate to them in your app. Here are some handy patterns for managing page data
|
37
|
+
in Storybook:
|
38
|
+
</p>
|
39
|
+
<ul>
|
40
|
+
<li>
|
41
|
+
Use a higher-level connected component. Storybook helps you compose such data from the
|
42
|
+
"args" of child component stories
|
43
|
+
</li>
|
44
|
+
<li>
|
45
|
+
Assemble data in the page component from your services. You can mock these services out
|
46
|
+
using Storybook.
|
47
|
+
</li>
|
48
|
+
</ul>
|
49
|
+
<p>
|
50
|
+
Get a guided tutorial on component-driven development at
|
51
|
+
<a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
|
52
|
+
Storybook tutorials
|
53
|
+
</a>
|
54
|
+
. Read more in the
|
55
|
+
<a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer"> docs </a>
|
56
|
+
.
|
57
|
+
</p>
|
58
|
+
<div class="tip-wrapper">
|
59
|
+
<span class="tip">Tip</span> Adjust the width of the canvas with the
|
60
|
+
<svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
|
61
|
+
<g fill="none" fillRule="evenodd">
|
62
|
+
<path
|
63
|
+
d="M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0 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 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"
|
64
|
+
id="a"
|
65
|
+
fill="#999"
|
66
|
+
/>
|
67
|
+
</g>
|
68
|
+
</svg>
|
69
|
+
Viewports addon in the toolbar
|
70
|
+
</div>
|
71
|
+
</section>
|
72
|
+
</article>
|
73
|
+
`;
|