@storybook/cli 7.0.0-alpha.46 → 7.0.0-alpha.47
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/generate.js +99 -99
- package/dist/generate.mjs +107 -107
- package/package.json +10 -10
- package/rendererAssets/angular/Button.stories.ts +0 -43
- package/rendererAssets/angular/Header.stories.ts +0 -35
- package/rendererAssets/angular/Page.stories.ts +0 -37
- package/rendererAssets/angular/User.ts +0 -2
- package/rendererAssets/angular/button.component.ts +0 -53
- package/rendererAssets/angular/header.component.ts +0 -75
- package/rendererAssets/angular/page.component.ts +0 -77
- package/rendererAssets/aurelia/1-Button.stories.ts +0 -49
- package/rendererAssets/aurelia/button.ts +0 -28
- package/rendererAssets/ember/1-Button.stories.js +0 -57
- package/rendererAssets/html/js/Button.js +0 -21
- package/rendererAssets/html/js/Button.stories.js +0 -48
- package/rendererAssets/html/js/Header.js +0 -47
- package/rendererAssets/html/js/Header.stories.js +0 -27
- package/rendererAssets/html/js/Page.js +0 -94
- package/rendererAssets/html/js/Page.stories.js +0 -23
- package/rendererAssets/html/ts/Button.stories.ts +0 -50
- package/rendererAssets/html/ts/Button.ts +0 -51
- package/rendererAssets/html/ts/Header.stories.ts +0 -27
- package/rendererAssets/html/ts/Header.ts +0 -54
- package/rendererAssets/html/ts/Page.stories.ts +0 -24
- package/rendererAssets/html/ts/Page.ts +0 -98
- package/rendererAssets/marionette/index.stories.js +0 -20
- package/rendererAssets/marko/1-Button.stories.js +0 -24
- package/rendererAssets/marko/Button.marko +0 -13
- package/rendererAssets/mithril/Button.js +0 -22
- package/rendererAssets/mithril/Button.stories.js +0 -43
- package/rendererAssets/mithril/Header.js +0 -51
- package/rendererAssets/mithril/Header.stories.js +0 -20
- package/rendererAssets/mithril/Page.js +0 -70
- package/rendererAssets/mithril/Page.stories.js +0 -24
- package/rendererAssets/nextjs/js/Button.jsx +0 -54
- package/rendererAssets/nextjs/js/Button.stories.jsx +0 -40
- package/rendererAssets/nextjs/js/Header.jsx +0 -57
- package/rendererAssets/nextjs/js/Header.stories.jsx +0 -24
- package/rendererAssets/nextjs/js/Introduction.stories.mdx +0 -228
- package/rendererAssets/nextjs/js/Page.jsx +0 -69
- package/rendererAssets/nextjs/js/Page.stories.jsx +0 -25
- package/rendererAssets/nextjs/ts/Button.stories.tsx +0 -41
- package/rendererAssets/nextjs/ts/Button.tsx +0 -52
- package/rendererAssets/nextjs/ts/Header.stories.tsx +0 -25
- package/rendererAssets/nextjs/ts/Header.tsx +0 -56
- package/rendererAssets/nextjs/ts/Introduction.stories.mdx +0 -228
- package/rendererAssets/nextjs/ts/Page.stories.tsx +0 -26
- package/rendererAssets/nextjs/ts/Page.tsx +0 -73
- package/rendererAssets/preact/Button.jsx +0 -49
- package/rendererAssets/preact/Button.stories.jsx +0 -39
- package/rendererAssets/preact/Header.jsx +0 -56
- package/rendererAssets/preact/Header.stories.jsx +0 -27
- package/rendererAssets/preact/Page.jsx +0 -69
- package/rendererAssets/preact/Page.stories.jsx +0 -24
- package/rendererAssets/rax/Button.js +0 -26
- package/rendererAssets/rax/Button.stories.js +0 -40
- package/rendererAssets/rax/Header.js +0 -44
- package/rendererAssets/rax/Header.stories.js +0 -17
- package/rendererAssets/rax/Page.js +0 -64
- package/rendererAssets/rax/Page.stories.js +0 -21
- package/rendererAssets/react/js/Button.jsx +0 -50
- package/rendererAssets/react/js/Button.stories.jsx +0 -40
- package/rendererAssets/react/js/Header.jsx +0 -57
- package/rendererAssets/react/js/Header.stories.jsx +0 -24
- package/rendererAssets/react/js/Page.jsx +0 -69
- package/rendererAssets/react/js/Page.stories.jsx +0 -25
- package/rendererAssets/react/ts/Button.stories.tsx +0 -41
- package/rendererAssets/react/ts/Button.tsx +0 -48
- package/rendererAssets/react/ts/Header.stories.tsx +0 -25
- package/rendererAssets/react/ts/Header.tsx +0 -56
- package/rendererAssets/react/ts/Page.stories.tsx +0 -26
- package/rendererAssets/react/ts/Page.tsx +0 -73
- package/rendererAssets/riot/1-Button.stories.js +0 -52
- package/rendererAssets/riot/MyButton.tag +0 -24
- package/rendererAssets/server/button.stories.json +0 -32
- package/rendererAssets/server/header.stories.json +0 -15
- package/rendererAssets/server/page.stories.json +0 -15
- package/rendererAssets/svelte/Button.stories.js +0 -51
- package/rendererAssets/svelte/Button.svelte +0 -43
- package/rendererAssets/svelte/Header.stories.js +0 -35
- package/rendererAssets/svelte/Header.svelte +0 -51
- package/rendererAssets/svelte/Page.stories.js +0 -27
- package/rendererAssets/svelte/Page.svelte +0 -63
- package/rendererAssets/vue/Button.stories.js +0 -46
- package/rendererAssets/vue/Button.vue +0 -54
- package/rendererAssets/vue/Header.stories.js +0 -27
- package/rendererAssets/vue/Header.vue +0 -51
- package/rendererAssets/vue/Page.stories.js +0 -27
- package/rendererAssets/vue/Page.vue +0 -88
- package/rendererAssets/vue3/Button.stories.js +0 -52
- package/rendererAssets/vue3/Button.vue +0 -52
- package/rendererAssets/vue3/Header.stories.js +0 -34
- package/rendererAssets/vue3/Header.vue +0 -41
- package/rendererAssets/vue3/Page.stories.js +0 -29
- package/rendererAssets/vue3/Page.vue +0 -88
- package/rendererAssets/web-components/js/Button.js +0 -21
- package/rendererAssets/web-components/js/Button.stories.js +0 -42
- package/rendererAssets/web-components/js/Header.js +0 -45
- package/rendererAssets/web-components/js/Header.stories.js +0 -15
- package/rendererAssets/web-components/js/Page.js +0 -61
- package/rendererAssets/web-components/js/Page.stories.js +0 -19
- package/rendererAssets/web-components/ts/Button.stories.ts +0 -44
- package/rendererAssets/web-components/ts/Button.ts +0 -43
- package/rendererAssets/web-components/ts/Header.stories.ts +0 -17
- package/rendererAssets/web-components/ts/Header.ts +0 -52
- package/rendererAssets/web-components/ts/Page.stories.ts +0 -21
- package/rendererAssets/web-components/ts/Page.ts +0 -68
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<header>
|
|
3
|
-
<div class="wrapper">
|
|
4
|
-
<div>
|
|
5
|
-
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
|
6
|
-
<g fill="none" fill-rule="evenodd">
|
|
7
|
-
<path d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z" fill="#FFF" />
|
|
8
|
-
<path d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z" fill="#555AB9" />
|
|
9
|
-
<path d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z" fill="#91BAF8" />
|
|
10
|
-
</g>
|
|
11
|
-
</svg>
|
|
12
|
-
<h1>Acme</h1>
|
|
13
|
-
</div>
|
|
14
|
-
<div>
|
|
15
|
-
<span class="welcome" v-if="user">Welcome, <b>{{ user.name }}</b>!</span>
|
|
16
|
-
<my-button size="small" @onClick="onLogout" label="Log out" v-if="user" />
|
|
17
|
-
<my-button size="small" @onClick="onLogin" label="Log in" v-if="!user" />
|
|
18
|
-
<my-button primary size="small" @onClick="onCreateAccount" label="Sign up" v-if="!user" />
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</header>
|
|
22
|
-
</template>
|
|
23
|
-
|
|
24
|
-
<script>
|
|
25
|
-
import './header.css';
|
|
26
|
-
import MyButton from './Button.vue';
|
|
27
|
-
|
|
28
|
-
export default {
|
|
29
|
-
name: 'my-header',
|
|
30
|
-
|
|
31
|
-
components: { MyButton },
|
|
32
|
-
|
|
33
|
-
props: {
|
|
34
|
-
user: {
|
|
35
|
-
type: Object,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
methods: {
|
|
40
|
-
onLogin() {
|
|
41
|
-
this.$emit('onLogin');
|
|
42
|
-
},
|
|
43
|
-
onLogout() {
|
|
44
|
-
this.$emit('onLogout');
|
|
45
|
-
},
|
|
46
|
-
onCreateAccount() {
|
|
47
|
-
this.$emit('onCreateAccount');
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
</script>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { within, userEvent } from '@storybook/testing-library';
|
|
2
|
-
|
|
3
|
-
import MyPage from './Page.vue';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Example/Page',
|
|
7
|
-
component: MyPage,
|
|
8
|
-
parameters: {
|
|
9
|
-
// More on Story layout: https://storybook.js.org/docs/vue/configure/story-layout
|
|
10
|
-
layout: 'fullscreen',
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const Template = () => ({
|
|
15
|
-
components: { MyPage },
|
|
16
|
-
template: '<my-page />',
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export const LoggedOut = Template.bind({});
|
|
20
|
-
|
|
21
|
-
// More on interaction testing: https://storybook.js.org/docs/vue/writing-tests/interaction-testing
|
|
22
|
-
export const LoggedIn = Template.bind({});
|
|
23
|
-
LoggedIn.play = async ({ canvasElement }) => {
|
|
24
|
-
const canvas = within(canvasElement);
|
|
25
|
-
const loginButton = await canvas.getByRole('button', { name: /Log in/i });
|
|
26
|
-
await userEvent.click(loginButton);
|
|
27
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<article>
|
|
3
|
-
<my-header
|
|
4
|
-
:user="user"
|
|
5
|
-
@onLogin="onLogin"
|
|
6
|
-
@onLogout="onLogout"
|
|
7
|
-
@onCreateAccount="onCreateAccount"
|
|
8
|
-
/>
|
|
9
|
-
|
|
10
|
-
<section>
|
|
11
|
-
<h2>Pages in Storybook</h2>
|
|
12
|
-
<p>
|
|
13
|
-
We recommend building UIs with a
|
|
14
|
-
<a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
|
|
15
|
-
<strong>component-driven</strong>
|
|
16
|
-
</a>
|
|
17
|
-
process starting with atomic components and ending with pages.
|
|
18
|
-
</p>
|
|
19
|
-
<p>
|
|
20
|
-
Render pages with mock data. This makes it easy to build and review page states without
|
|
21
|
-
needing to navigate to them in your app. Here are some handy patterns for managing page data
|
|
22
|
-
in Storybook:
|
|
23
|
-
</p>
|
|
24
|
-
<ul>
|
|
25
|
-
<li>
|
|
26
|
-
Use a higher-level connected component. Storybook helps you compose such data from the
|
|
27
|
-
"args" of child component stories
|
|
28
|
-
</li>
|
|
29
|
-
<li>
|
|
30
|
-
Assemble data in the page component from your services. You can mock these services out
|
|
31
|
-
using Storybook.
|
|
32
|
-
</li>
|
|
33
|
-
</ul>
|
|
34
|
-
<p>
|
|
35
|
-
Get a guided tutorial on component-driven development at
|
|
36
|
-
<a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer"
|
|
37
|
-
>Storybook tutorials</a
|
|
38
|
-
>
|
|
39
|
-
. Read more in the
|
|
40
|
-
<a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">docs</a>
|
|
41
|
-
.
|
|
42
|
-
</p>
|
|
43
|
-
<div class="tip-wrapper">
|
|
44
|
-
<span class="tip">Tip</span>
|
|
45
|
-
Adjust the width of the canvas with the
|
|
46
|
-
<svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
|
|
47
|
-
<g fill="none" fill-rule="evenodd">
|
|
48
|
-
<path
|
|
49
|
-
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"
|
|
50
|
-
id="a"
|
|
51
|
-
fill="#999"
|
|
52
|
-
/>
|
|
53
|
-
</g>
|
|
54
|
-
</svg>
|
|
55
|
-
Viewports addon in the toolbar
|
|
56
|
-
</div>
|
|
57
|
-
</section>
|
|
58
|
-
</article>
|
|
59
|
-
</template>
|
|
60
|
-
|
|
61
|
-
<script>
|
|
62
|
-
import './page.css';
|
|
63
|
-
import MyHeader from './Header.vue';
|
|
64
|
-
|
|
65
|
-
export default {
|
|
66
|
-
name: 'my-page',
|
|
67
|
-
|
|
68
|
-
components: { MyHeader },
|
|
69
|
-
|
|
70
|
-
data() {
|
|
71
|
-
return {
|
|
72
|
-
user: null,
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
methods: {
|
|
77
|
-
onLogin() {
|
|
78
|
-
this.user = { name: 'Jane Doe' };
|
|
79
|
-
},
|
|
80
|
-
onLogout() {
|
|
81
|
-
this.user = null;
|
|
82
|
-
},
|
|
83
|
-
onCreateAccount() {
|
|
84
|
-
this.user = { name: 'Jane Doe' };
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
</script>
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import MyButton from './Button.vue';
|
|
2
|
-
|
|
3
|
-
// More on default export: https://storybook.js.org/docs/vue/writing-stories/introduction#default-export
|
|
4
|
-
export default {
|
|
5
|
-
title: 'Example/Button',
|
|
6
|
-
component: MyButton,
|
|
7
|
-
// More on argTypes: https://storybook.js.org/docs/vue/api/argtypes
|
|
8
|
-
argTypes: {
|
|
9
|
-
backgroundColor: { control: 'color' },
|
|
10
|
-
onClick: {},
|
|
11
|
-
size: {
|
|
12
|
-
control: { type: 'select' },
|
|
13
|
-
options: ['small', 'medium', 'large'],
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// More on component templates: https://storybook.js.org/docs/vue/writing-stories/introduction#using-args
|
|
19
|
-
const Template = (args) => ({
|
|
20
|
-
// Components used in your story `template` are defined in the `components` object
|
|
21
|
-
components: { MyButton },
|
|
22
|
-
// The story's `args` need to be mapped into the template through the `setup()` method
|
|
23
|
-
setup() {
|
|
24
|
-
return { args };
|
|
25
|
-
},
|
|
26
|
-
// And then the `args` are bound to your component with `v-bind="args"`
|
|
27
|
-
template: '<my-button v-bind="args" />',
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export const Primary = Template.bind({});
|
|
31
|
-
// More on args: https://storybook.js.org/docs/vue/writing-stories/args
|
|
32
|
-
Primary.args = {
|
|
33
|
-
primary: true,
|
|
34
|
-
label: 'Button',
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const Secondary = Template.bind({});
|
|
38
|
-
Secondary.args = {
|
|
39
|
-
label: 'Button',
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const Large = Template.bind({});
|
|
43
|
-
Large.args = {
|
|
44
|
-
size: 'large',
|
|
45
|
-
label: 'Button',
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const Small = Template.bind({});
|
|
49
|
-
Small.args = {
|
|
50
|
-
size: 'small',
|
|
51
|
-
label: 'Button',
|
|
52
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<button type="button" :class="classes" @click="onClick" :style="style">{{ label }}</button>
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script>
|
|
6
|
-
import './button.css';
|
|
7
|
-
import { reactive, computed } from 'vue';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
name: 'my-button',
|
|
11
|
-
|
|
12
|
-
props: {
|
|
13
|
-
label: {
|
|
14
|
-
type: String,
|
|
15
|
-
required: true,
|
|
16
|
-
},
|
|
17
|
-
primary: {
|
|
18
|
-
type: Boolean,
|
|
19
|
-
default: false,
|
|
20
|
-
},
|
|
21
|
-
size: {
|
|
22
|
-
type: String,
|
|
23
|
-
validator: function (value) {
|
|
24
|
-
return ['small', 'medium', 'large'].indexOf(value) !== -1;
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
backgroundColor: {
|
|
28
|
-
type: String,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
emits: ['click'],
|
|
33
|
-
|
|
34
|
-
setup(props, { emit }) {
|
|
35
|
-
props = reactive(props);
|
|
36
|
-
return {
|
|
37
|
-
classes: computed(() => ({
|
|
38
|
-
'storybook-button': true,
|
|
39
|
-
'storybook-button--primary': props.primary,
|
|
40
|
-
'storybook-button--secondary': !props.primary,
|
|
41
|
-
[`storybook-button--${props.size || 'medium'}`]: true,
|
|
42
|
-
})),
|
|
43
|
-
style: computed(() => ({
|
|
44
|
-
backgroundColor: props.backgroundColor,
|
|
45
|
-
})),
|
|
46
|
-
onClick() {
|
|
47
|
-
emit('click');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
</script>
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import MyHeader from './Header.vue';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'Example/Header',
|
|
5
|
-
component: MyHeader,
|
|
6
|
-
parameters: {
|
|
7
|
-
// More on Story layout: https://storybook.js.org/docs/vue/configure/story-layout
|
|
8
|
-
layout: 'fullscreen',
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const Template = (args) => ({
|
|
13
|
-
// Components used in your story `template` are defined in the `components` object
|
|
14
|
-
components: { MyHeader },
|
|
15
|
-
// The story's `args` need to be mapped into the template through the `setup()` method
|
|
16
|
-
setup() {
|
|
17
|
-
// Story args can be spread into the returned object
|
|
18
|
-
return { ...args };
|
|
19
|
-
},
|
|
20
|
-
// Then, the spread values can be accessed directly in the template
|
|
21
|
-
template: '<my-header :user="user" />',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export const LoggedIn = Template.bind({});
|
|
25
|
-
LoggedIn.args = {
|
|
26
|
-
user: {
|
|
27
|
-
name: 'Jane Doe',
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const LoggedOut = Template.bind({});
|
|
32
|
-
LoggedOut.args = {
|
|
33
|
-
user: null,
|
|
34
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<header>
|
|
3
|
-
<div class="wrapper">
|
|
4
|
-
<div>
|
|
5
|
-
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
|
6
|
-
<g fill="none" fill-rule="evenodd">
|
|
7
|
-
<path d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z" fill="#FFF" />
|
|
8
|
-
<path d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z" fill="#555AB9" />
|
|
9
|
-
<path d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z" fill="#91BAF8" />
|
|
10
|
-
</g>
|
|
11
|
-
</svg>
|
|
12
|
-
<h1>Acme</h1>
|
|
13
|
-
</div>
|
|
14
|
-
<div>
|
|
15
|
-
<span class="welcome" v-if="user">Welcome, <b>{{ user.name }}</b>!</span>
|
|
16
|
-
<my-button size="small" @click="$emit('logout')" label="Log out" v-if="user" />
|
|
17
|
-
<my-button size="small" @click="$emit('login')" label="Log in" v-if="!user" />
|
|
18
|
-
<my-button primary size="small" @click="$emit('createAccount')" label="Sign up" v-if="!user" />
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</header>
|
|
22
|
-
</template>
|
|
23
|
-
|
|
24
|
-
<script>
|
|
25
|
-
import './header.css';
|
|
26
|
-
import MyButton from './Button.vue';
|
|
27
|
-
|
|
28
|
-
export default {
|
|
29
|
-
name: 'my-header',
|
|
30
|
-
|
|
31
|
-
components: { MyButton },
|
|
32
|
-
|
|
33
|
-
props: {
|
|
34
|
-
user: {
|
|
35
|
-
type: Object,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
emits: ['login', 'logout', 'createAccount'],
|
|
40
|
-
};
|
|
41
|
-
</script>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { within, userEvent } from '@storybook/testing-library';
|
|
2
|
-
import MyPage from './Page.vue';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
title: 'Example/Page',
|
|
6
|
-
component: MyPage,
|
|
7
|
-
parameters: {
|
|
8
|
-
// More on Story layout: https://storybook.js.org/docs/vue/configure/story-layout
|
|
9
|
-
layout: 'fullscreen',
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const Template = () => ({
|
|
14
|
-
// Components used in your story `template` are defined in the `components` object
|
|
15
|
-
components: { MyPage },
|
|
16
|
-
|
|
17
|
-
// Here we define the `template`
|
|
18
|
-
template: '<my-page />',
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export const LoggedOut = Template.bind({});
|
|
22
|
-
|
|
23
|
-
// More on interaction testing: https://storybook.js.org/docs/vue/writing-tests/interaction-testing
|
|
24
|
-
export const LoggedIn = Template.bind({});
|
|
25
|
-
LoggedIn.play = async ({ canvasElement }) => {
|
|
26
|
-
const canvas = within(canvasElement);
|
|
27
|
-
const loginButton = await canvas.getByRole('button', { name: /Log in/i });
|
|
28
|
-
await userEvent.click(loginButton);
|
|
29
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<article>
|
|
3
|
-
<my-header
|
|
4
|
-
:user="user"
|
|
5
|
-
@login="onLogin"
|
|
6
|
-
@logout="onLogout"
|
|
7
|
-
@createAccount="onCreateAccount"
|
|
8
|
-
/>
|
|
9
|
-
|
|
10
|
-
<section>
|
|
11
|
-
<h2>Pages in Storybook</h2>
|
|
12
|
-
<p>
|
|
13
|
-
We recommend building UIs with a
|
|
14
|
-
<a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
|
|
15
|
-
<strong>component-driven</strong>
|
|
16
|
-
</a>
|
|
17
|
-
process starting with atomic components and ending with pages.
|
|
18
|
-
</p>
|
|
19
|
-
<p>
|
|
20
|
-
Render pages with mock data. This makes it easy to build and review page states without
|
|
21
|
-
needing to navigate to them in your app. Here are some handy patterns for managing page data
|
|
22
|
-
in Storybook:
|
|
23
|
-
</p>
|
|
24
|
-
<ul>
|
|
25
|
-
<li>
|
|
26
|
-
Use a higher-level connected component. Storybook helps you compose such data from the
|
|
27
|
-
"args" of child component stories
|
|
28
|
-
</li>
|
|
29
|
-
<li>
|
|
30
|
-
Assemble data in the page component from your services. You can mock these services out
|
|
31
|
-
using Storybook.
|
|
32
|
-
</li>
|
|
33
|
-
</ul>
|
|
34
|
-
<p>
|
|
35
|
-
Get a guided tutorial on component-driven development at
|
|
36
|
-
<a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer"
|
|
37
|
-
>Storybook tutorials</a
|
|
38
|
-
>
|
|
39
|
-
. Read more in the
|
|
40
|
-
<a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">docs</a>
|
|
41
|
-
.
|
|
42
|
-
</p>
|
|
43
|
-
<div class="tip-wrapper">
|
|
44
|
-
<span class="tip">Tip</span>
|
|
45
|
-
Adjust the width of the canvas with the
|
|
46
|
-
<svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
|
|
47
|
-
<g fill="none" fill-rule="evenodd">
|
|
48
|
-
<path
|
|
49
|
-
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"
|
|
50
|
-
id="a"
|
|
51
|
-
fill="#999"
|
|
52
|
-
/>
|
|
53
|
-
</g>
|
|
54
|
-
</svg>
|
|
55
|
-
Viewports addon in the toolbar
|
|
56
|
-
</div>
|
|
57
|
-
</section>
|
|
58
|
-
</article>
|
|
59
|
-
</template>
|
|
60
|
-
|
|
61
|
-
<script>
|
|
62
|
-
import './page.css';
|
|
63
|
-
import MyHeader from './Header.vue';
|
|
64
|
-
|
|
65
|
-
export default {
|
|
66
|
-
name: 'my-page',
|
|
67
|
-
|
|
68
|
-
components: { MyHeader },
|
|
69
|
-
|
|
70
|
-
data() {
|
|
71
|
-
return {
|
|
72
|
-
user: null
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
methods: {
|
|
77
|
-
onLogin() {
|
|
78
|
-
this.user = { name: 'Jane Doe' };
|
|
79
|
-
},
|
|
80
|
-
onLogout() {
|
|
81
|
-
this.user = null;
|
|
82
|
-
},
|
|
83
|
-
onCreateAccount() {
|
|
84
|
-
this.user = { name: 'Jane Doe' };
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
</script>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit-html';
|
|
2
|
-
import { styleMap } from 'lit-html/directives/style-map.js';
|
|
3
|
-
import './button.css';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Primary UI component for user interaction
|
|
7
|
-
*/
|
|
8
|
-
export const Button = ({ primary, backgroundColor = null, size, label, onClick }) => {
|
|
9
|
-
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
10
|
-
|
|
11
|
-
return html`
|
|
12
|
-
<button
|
|
13
|
-
type="button"
|
|
14
|
-
class=${['storybook-button', `storybook-button--${size || 'medium'}`, mode].join(' ')}
|
|
15
|
-
style=${styleMap({ backgroundColor })}
|
|
16
|
-
@click=${onClick}
|
|
17
|
-
>
|
|
18
|
-
${label}
|
|
19
|
-
</button>
|
|
20
|
-
`;
|
|
21
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Button } from './Button';
|
|
2
|
-
|
|
3
|
-
// More on default export: https://storybook.js.org/docs/web-components/writing-stories/introduction#default-export
|
|
4
|
-
export default {
|
|
5
|
-
title: 'Example/Button',
|
|
6
|
-
// More on argTypes: https://storybook.js.org/docs/web-components/api/argtypes
|
|
7
|
-
argTypes: {
|
|
8
|
-
backgroundColor: { control: 'color' },
|
|
9
|
-
onClick: { action: 'onClick' },
|
|
10
|
-
size: {
|
|
11
|
-
control: { type: 'select' },
|
|
12
|
-
options: ['small', 'medium', 'large'],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// More on component templates: https://storybook.js.org/docs/web-components/writing-stories/introduction#using-args
|
|
18
|
-
const Template = (args) => Button(args);
|
|
19
|
-
|
|
20
|
-
export const Primary = Template.bind({});
|
|
21
|
-
// More on args: https://storybook.js.org/docs/web-components/writing-stories/args
|
|
22
|
-
Primary.args = {
|
|
23
|
-
primary: true,
|
|
24
|
-
label: 'Button',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const Secondary = Template.bind({});
|
|
28
|
-
Secondary.args = {
|
|
29
|
-
label: 'Button',
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const Large = Template.bind({});
|
|
33
|
-
Large.args = {
|
|
34
|
-
size: 'large',
|
|
35
|
-
label: 'Button',
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const Small = Template.bind({});
|
|
39
|
-
Small.args = {
|
|
40
|
-
size: 'small',
|
|
41
|
-
label: 'Button',
|
|
42
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit-html';
|
|
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="wrapper">
|
|
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
|
-
`;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Header } from './Header';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'Example/Header',
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const Template = (args) => Header(args);
|
|
8
|
-
|
|
9
|
-
export const LoggedIn = Template.bind({});
|
|
10
|
-
LoggedIn.args = {
|
|
11
|
-
user: {},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const LoggedOut = Template.bind({});
|
|
15
|
-
LoggedOut.args = {};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit-html';
|
|
2
|
-
import { Header } from './Header';
|
|
3
|
-
import './page.css';
|
|
4
|
-
|
|
5
|
-
export const Page = ({ user, onLogin, onLogout, onCreateAccount }) => html`
|
|
6
|
-
<article>
|
|
7
|
-
${Header({
|
|
8
|
-
user,
|
|
9
|
-
onLogin,
|
|
10
|
-
onLogout,
|
|
11
|
-
onCreateAccount,
|
|
12
|
-
})}
|
|
13
|
-
|
|
14
|
-
<section>
|
|
15
|
-
<h2>Pages in Storybook</h2>
|
|
16
|
-
<p>
|
|
17
|
-
We recommend building UIs with a
|
|
18
|
-
<a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
|
|
19
|
-
<strong>component-driven</strong> </a
|
|
20
|
-
>process starting with atomic components and ending with pages.
|
|
21
|
-
</p>
|
|
22
|
-
<p>
|
|
23
|
-
Render pages with mock data. This makes it easy to build and review page states without
|
|
24
|
-
needing to navigate to them in your app. Here are some handy patterns for managing page data
|
|
25
|
-
in Storybook:
|
|
26
|
-
</p>
|
|
27
|
-
<ul>
|
|
28
|
-
<li>
|
|
29
|
-
Use a higher-level connected component. Storybook helps you compose such data from the
|
|
30
|
-
"args" of child component stories
|
|
31
|
-
</li>
|
|
32
|
-
<li>
|
|
33
|
-
Assemble data in the page component from your services. You can mock these services out
|
|
34
|
-
using Storybook.
|
|
35
|
-
</li>
|
|
36
|
-
</ul>
|
|
37
|
-
<p>
|
|
38
|
-
Get a guided tutorial on component-driven development at
|
|
39
|
-
<a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
|
|
40
|
-
Storybook tutorials
|
|
41
|
-
</a>
|
|
42
|
-
. Read more in the
|
|
43
|
-
<a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer"> docs </a>
|
|
44
|
-
.
|
|
45
|
-
</p>
|
|
46
|
-
<div class="tip-wrapper">
|
|
47
|
-
<span class="tip">Tip</span> Adjust the width of the canvas with the
|
|
48
|
-
<svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
|
|
49
|
-
<g fill="none" fillRule="evenodd">
|
|
50
|
-
<path
|
|
51
|
-
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"
|
|
52
|
-
id="a"
|
|
53
|
-
fill="#999"
|
|
54
|
-
/>
|
|
55
|
-
</g>
|
|
56
|
-
</svg>
|
|
57
|
-
Viewports addon in the toolbar
|
|
58
|
-
</div>
|
|
59
|
-
</section>
|
|
60
|
-
</article>
|
|
61
|
-
`;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Page } from './Page';
|
|
2
|
-
import * as HeaderStories from './Header.stories';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
title: 'Example/Page',
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const Template = (args) => Page(args);
|
|
9
|
-
|
|
10
|
-
export const LoggedIn = Template.bind({});
|
|
11
|
-
LoggedIn.args = {
|
|
12
|
-
// More on composing args: https://storybook.js.org/docs/web-components/writing-stories/args#args-composition
|
|
13
|
-
...HeaderStories.LoggedIn.args,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const LoggedOut = Template.bind({});
|
|
17
|
-
LoggedOut.args = {
|
|
18
|
-
...HeaderStories.LoggedOut.args,
|
|
19
|
-
};
|