@storybook/web-components 7.0.0-rc.4 → 7.0.0-rc.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/web-components",
3
- "version": "7.0.0-rc.4",
3
+ "version": "7.0.0-rc.6",
4
4
  "description": "Storybook web-components renderer",
5
5
  "keywords": [
6
6
  "lit",
@@ -51,13 +51,13 @@
51
51
  "prep": "../../../scripts/prepare/bundle.ts"
52
52
  },
53
53
  "dependencies": {
54
- "@storybook/client-logger": "7.0.0-rc.4",
55
- "@storybook/core-client": "7.0.0-rc.4",
56
- "@storybook/docs-tools": "7.0.0-rc.4",
54
+ "@storybook/client-logger": "7.0.0-rc.6",
55
+ "@storybook/core-client": "7.0.0-rc.6",
56
+ "@storybook/docs-tools": "7.0.0-rc.6",
57
57
  "@storybook/global": "^5.0.0",
58
- "@storybook/manager-api": "7.0.0-rc.4",
59
- "@storybook/preview-api": "7.0.0-rc.4",
60
- "@storybook/types": "7.0.0-rc.4",
58
+ "@storybook/manager-api": "7.0.0-rc.6",
59
+ "@storybook/preview-api": "7.0.0-rc.6",
60
+ "@storybook/types": "7.0.0-rc.6",
61
61
  "ts-dedent": "^2.0.0"
62
62
  },
63
63
  "devDependencies": {
@@ -84,5 +84,5 @@
84
84
  ],
85
85
  "platform": "browser"
86
86
  },
87
- "gitHead": "6fb713a2ca980fa241f82a076579889fcdf47ecc"
87
+ "gitHead": "1467fa1d714cbf43d5d87f9233c6dd42e20da787"
88
88
  }
@@ -0,0 +1,49 @@
1
+ import type { Meta, StoryObj } from '@storybook/web-components';
2
+ import type { ButtonProps } from './Button';
3
+ import { Button } from './Button';
4
+
5
+ // More on how to set up stories at: https://storybook.js.org/docs/7.0/web-components/writing-stories/introduction
6
+ const meta = {
7
+ title: 'Example/Button',
8
+ tags: ['autodocs'],
9
+ render: (args) => Button(args),
10
+ argTypes: {
11
+ backgroundColor: { control: 'color' },
12
+ onClick: { action: 'onClick' },
13
+ size: {
14
+ control: { type: 'select' },
15
+ options: ['small', 'medium', 'large'],
16
+ },
17
+ },
18
+ } satisfies Meta<ButtonProps>;
19
+
20
+ export default meta;
21
+ type Story = StoryObj<ButtonProps>;
22
+
23
+ // More on writing stories with args: https://storybook.js.org/docs/7.0/web-components/writing-stories/args
24
+ export const Primary: Story = {
25
+ args: {
26
+ primary: true,
27
+ label: 'Button',
28
+ },
29
+ };
30
+
31
+ export const Secondary: Story = {
32
+ args: {
33
+ label: 'Button',
34
+ },
35
+ };
36
+
37
+ export const Large: Story = {
38
+ args: {
39
+ size: 'large',
40
+ label: 'Button',
41
+ },
42
+ };
43
+
44
+ export const Small: Story = {
45
+ args: {
46
+ size: 'small',
47
+ label: 'Button',
48
+ },
49
+ };
@@ -0,0 +1,43 @@
1
+ import { html } from 'lit';
2
+ import { styleMap } from 'lit/directives/style-map.js';
3
+ import './button.css';
4
+
5
+ export interface ButtonProps {
6
+ /**
7
+ * Is this the principal call to action on the page?
8
+ */
9
+ primary?: boolean;
10
+ /**
11
+ * What background color to use
12
+ */
13
+ backgroundColor?: string;
14
+ /**
15
+ * How large should the button be?
16
+ */
17
+ size?: 'small' | 'medium' | 'large';
18
+ /**
19
+ * Button contents
20
+ */
21
+ label: string;
22
+ /**
23
+ * Optional click handler
24
+ */
25
+ onClick?: () => void;
26
+ }
27
+ /**
28
+ * Primary UI component for user interaction
29
+ */
30
+ export const Button = ({ primary, backgroundColor, size, label, onClick }: ButtonProps) => {
31
+ const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
32
+
33
+ return html`
34
+ <button
35
+ type="button"
36
+ class=${['storybook-button', `storybook-button--${size || 'medium'}`, mode].join(' ')}
37
+ style=${styleMap({ backgroundColor })}
38
+ @click=${onClick}
39
+ >
40
+ ${label}
41
+ </button>
42
+ `;
43
+ };
@@ -0,0 +1,23 @@
1
+ import type { Meta, StoryObj } from '@storybook/web-components';
2
+ import type { HeaderProps } from './Header';
3
+ import { Header } from './Header';
4
+
5
+ const meta = {
6
+ title: 'Example/Header',
7
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/7.0/web-components/writing-docs/docs-page
8
+ tags: ['autodocs'],
9
+ render: (args: HeaderProps) => Header(args),
10
+ } satisfies Meta<HeaderProps>;
11
+
12
+ export default meta;
13
+ type Story = StoryObj<HeaderProps>;
14
+
15
+ export const LoggedIn: Story = {
16
+ args: {
17
+ user: {
18
+ name: 'Jane Doe',
19
+ },
20
+ },
21
+ };
22
+
23
+ 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="wrapper">
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';
2
+
3
+ import type { PageProps } from './Page';
4
+ import { Page } from './Page';
5
+ import * as HeaderStories from './Header.stories';
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/7.0/web-components/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,72 @@
1
+ import { html } from 'lit';
2
+ import { Header } from './Header';
3
+ import './page.css';
4
+
5
+ type User = {
6
+ name: string;
7
+ };
8
+
9
+ export interface PageProps {
10
+ user?: User;
11
+ onLogin: () => void;
12
+ onLogout: () => void;
13
+ onCreateAccount: () => void;
14
+ }
15
+
16
+ export const Page = ({ user, onLogin, onLogout, onCreateAccount }: PageProps) => html`
17
+ <article>
18
+ ${Header({
19
+ user,
20
+ onLogin,
21
+ onLogout,
22
+ onCreateAccount,
23
+ })}
24
+
25
+ <section>
26
+ <h2>Pages in Storybook</h2>
27
+ <p>
28
+ We recommend building UIs with a
29
+ <a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
30
+ <strong>component-driven</strong> </a
31
+ >process starting with atomic components and ending with pages.
32
+ </p>
33
+ <p>
34
+ Render pages with mock data. This makes it easy to build and review page states without
35
+ needing to navigate to them in your app. Here are some handy patterns for managing page data
36
+ in Storybook:
37
+ </p>
38
+ <ul>
39
+ <li>
40
+ Use a higher-level connected component. Storybook helps you compose such data from the
41
+ "args" of child component stories
42
+ </li>
43
+ <li>
44
+ Assemble data in the page component from your services. You can mock these services out
45
+ using Storybook.
46
+ </li>
47
+ </ul>
48
+ <p>
49
+ Get a guided tutorial on component-driven development at
50
+ <a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
51
+ Storybook tutorials
52
+ </a>
53
+ . Read more in the
54
+ <a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer"> docs </a>
55
+ .
56
+ </p>
57
+ <div class="tip-wrapper">
58
+ <span class="tip">Tip</span> Adjust the width of the canvas with the
59
+ <svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
60
+ <g fill="none" fillRule="evenodd">
61
+ <path
62
+ 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"
63
+ id="a"
64
+ fill="#999"
65
+ />
66
+ </g>
67
+ </svg>
68
+ Viewports addon in the toolbar
69
+ </div>
70
+ </section>
71
+ </article>
72
+ `;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes