@storybook/web-components 9.0.0-alpha.0 → 9.0.0-alpha.2

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": "9.0.0-alpha.0",
3
+ "version": "9.0.0-alpha.2",
4
4
  "description": "Storybook web-components renderer",
5
5
  "keywords": [
6
6
  "lit",
@@ -49,11 +49,7 @@
49
49
  "prep": "jiti ../../../scripts/prepare/bundle.ts"
50
50
  },
51
51
  "dependencies": {
52
- "@storybook/components": "9.0.0-alpha.0",
53
52
  "@storybook/global": "^5.0.0",
54
- "@storybook/manager-api": "9.0.0-alpha.0",
55
- "@storybook/preview-api": "9.0.0-alpha.0",
56
- "@storybook/theming": "9.0.0-alpha.0",
57
53
  "tiny-invariant": "^1.3.1",
58
54
  "ts-dedent": "^2.0.0"
59
55
  },
@@ -67,7 +63,7 @@
67
63
  },
68
64
  "peerDependencies": {
69
65
  "lit": "^2.0.0 || ^3.0.0",
70
- "storybook": "^9.0.0-alpha.0"
66
+ "storybook": "^9.0.0-alpha.2"
71
67
  },
72
68
  "engines": {
73
69
  "node": ">=18.0.0"
@@ -1,52 +0,0 @@
1
- import { fn } from '@storybook/test';
2
-
3
- import type { Meta, StoryObj } from '@storybook/web-components';
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: Meta<ButtonProps> = {
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
- };
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
- };
@@ -1,32 +0,0 @@
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
- };
@@ -1,31 +0,0 @@
1
- import { fn } from '@storybook/test';
2
-
3
- import type { Meta, StoryObj } from '@storybook/web-components';
4
-
5
- import type { HeaderProps } from './Header';
6
- import { Header } from './Header';
7
-
8
- const meta: Meta<HeaderProps> = {
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
- };
19
-
20
- export default meta;
21
- type Story = StoryObj<HeaderProps>;
22
-
23
- export const LoggedIn: Story = {
24
- args: {
25
- user: {
26
- name: 'Jonh Doe',
27
- },
28
- },
29
- };
30
-
31
- export const LoggedOut: Story = {};
@@ -1,56 +0,0 @@
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
- `;
@@ -1,26 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/web-components';
2
-
3
- import * as HeaderStories from './Header.stories';
4
- import type { PageProps } from './Page';
5
- import { Page } from './Page';
6
-
7
- const meta: Meta<PageProps> = {
8
- title: 'Example/Page',
9
- render: (args: PageProps) => Page(args),
10
- };
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
- };
@@ -1,73 +0,0 @@
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
- `;