@storybook/nextjs 7.0.0-beta.43 → 7.0.0-beta.45

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/nextjs",
3
- "version": "7.0.0-beta.43",
3
+ "version": "7.0.0-beta.45",
4
4
  "description": "Storybook for Next.js",
5
5
  "keywords": [
6
6
  "storybook",
@@ -60,13 +60,13 @@
60
60
  },
61
61
  "dependencies": {
62
62
  "@next/font": "^13.0.7",
63
- "@storybook/addon-actions": "7.0.0-beta.43",
64
- "@storybook/builder-webpack5": "7.0.0-beta.43",
65
- "@storybook/core-common": "7.0.0-beta.43",
66
- "@storybook/node-logger": "7.0.0-beta.43",
67
- "@storybook/preset-react-webpack": "7.0.0-beta.43",
68
- "@storybook/preview-api": "7.0.0-beta.43",
69
- "@storybook/react": "7.0.0-beta.43",
63
+ "@storybook/addon-actions": "7.0.0-beta.45",
64
+ "@storybook/builder-webpack5": "7.0.0-beta.45",
65
+ "@storybook/core-common": "7.0.0-beta.45",
66
+ "@storybook/node-logger": "7.0.0-beta.45",
67
+ "@storybook/preset-react-webpack": "7.0.0-beta.45",
68
+ "@storybook/preview-api": "7.0.0-beta.45",
69
+ "@storybook/react": "7.0.0-beta.45",
70
70
  "@types/node": "^16.0.0",
71
71
  "find-up": "^5.0.0",
72
72
  "fs-extra": "^11.1.0",
@@ -123,5 +123,5 @@
123
123
  ],
124
124
  "platform": "node"
125
125
  },
126
- "gitHead": "b1b7c2bc998decc21eb8352fcccd3c939048df02"
126
+ "gitHead": "c7fdb03a408aff39160d1977f906e1780ccfbc50"
127
127
  }
@@ -224,5 +224,5 @@ We recommend building UIs with a [**component-driven**](https://componentdriven.
224
224
  </div>
225
225
 
226
226
  <div className="tip-wrapper">
227
- <span className="tip">Tip</span>Edit the Markdown in <code>stories/Introduction.stories.mdx</code>
227
+ <span className="tip">Tip</span>Edit the Markdown in <code>stories/Introduction.mdx</code>
228
228
  </div>
@@ -0,0 +1,46 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { Button } from './Button';
4
+
5
+ // More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
6
+ const meta: Meta<typeof Button> = {
7
+ title: 'Example/Button',
8
+ component: Button,
9
+ tags: ['autodocs'],
10
+ argTypes: {
11
+ backgroundColor: {
12
+ control: 'color',
13
+ },
14
+ },
15
+ };
16
+
17
+ export default meta;
18
+ type Story = StoryObj<typeof Button>;
19
+
20
+ // More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args
21
+ export const Primary: Story = {
22
+ args: {
23
+ primary: true,
24
+ label: 'Button',
25
+ },
26
+ };
27
+
28
+ export const Secondary: Story = {
29
+ args: {
30
+ label: 'Button',
31
+ },
32
+ };
33
+
34
+ export const Large: Story = {
35
+ args: {
36
+ size: 'large',
37
+ label: 'Button',
38
+ },
39
+ };
40
+
41
+ export const Small: Story = {
42
+ args: {
43
+ size: 'small',
44
+ label: 'Button',
45
+ },
46
+ };
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import './button.css';
3
+
4
+ interface ButtonProps {
5
+ /**
6
+ * Is this the principal call to action on the page?
7
+ */
8
+ primary?: boolean;
9
+ /**
10
+ * What background color to use
11
+ */
12
+ backgroundColor?: string;
13
+ /**
14
+ * How large should the button be?
15
+ */
16
+ size?: 'small' | 'medium' | 'large';
17
+ /**
18
+ * Button contents
19
+ */
20
+ label: string;
21
+ /**
22
+ * Optional click handler
23
+ */
24
+ onClick?: () => void;
25
+ }
26
+
27
+ /**
28
+ * Primary UI component for user interaction
29
+ */
30
+ export const Button = ({
31
+ primary = false,
32
+ size = 'medium',
33
+ backgroundColor,
34
+ label,
35
+ ...props
36
+ }: ButtonProps) => {
37
+ const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
38
+ return (
39
+ <button
40
+ type="button"
41
+ className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
42
+ {...props}
43
+ >
44
+ {label}
45
+ <style jsx>{`
46
+ button {
47
+ background-color: ${backgroundColor};
48
+ }
49
+ `}</style>
50
+ </button>
51
+ );
52
+ };
@@ -0,0 +1,26 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Header } from './Header';
3
+
4
+ const meta: Meta<typeof Header> = {
5
+ title: 'Example/Header',
6
+ component: Header,
7
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/7.0/react/writing-docs/docs-page
8
+ tags: ['autodocs'],
9
+ parameters: {
10
+ // More on how to position stories at: https://storybook.js.org/docs/7.0/react/configure/story-layout
11
+ layout: 'fullscreen',
12
+ },
13
+ };
14
+
15
+ export default meta;
16
+ type Story = StoryObj<typeof Header>;
17
+
18
+ export const LoggedIn: Story = {
19
+ args: {
20
+ user: {
21
+ name: 'Jane Doe',
22
+ },
23
+ },
24
+ };
25
+
26
+ export const LoggedOut: Story = {};
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+
3
+ import { Button } from './Button';
4
+ import './header.css';
5
+
6
+ type User = {
7
+ name: string;
8
+ };
9
+
10
+ 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) => (
18
+ <header>
19
+ <div className="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
+ <>
42
+ <span className="welcome">
43
+ Welcome, <b>{user.name}</b>!
44
+ </span>
45
+ <Button size="small" onClick={onLogout} label="Log out" />
46
+ </>
47
+ ) : (
48
+ <>
49
+ <Button size="small" onClick={onLogin} label="Log in" />
50
+ <Button primary size="small" onClick={onCreateAccount} label="Sign up" />
51
+ </>
52
+ )}
53
+ </div>
54
+ </div>
55
+ </header>
56
+ );
@@ -0,0 +1,228 @@
1
+ import { Meta } from '@storybook/blocks';
2
+ import Image from 'next/image';
3
+
4
+ import Code from './assets/code-brackets.svg';
5
+ import Colors from './assets/colors.svg';
6
+ import Comments from './assets/comments.svg';
7
+ import Direction from './assets/direction.svg';
8
+ import Flow from './assets/flow.svg';
9
+ import Plugin from './assets/plugin.svg';
10
+ import Repo from './assets/repo.svg';
11
+ import StackAlt from './assets/stackalt.svg';
12
+
13
+ <Meta title="Example/Introduction" />
14
+
15
+ <style>
16
+ {`
17
+ .subheading {
18
+ --mediumdark: '#999999';
19
+ font-weight: 900;
20
+ font-size: 13px;
21
+ color: #999;
22
+ letter-spacing: 6px;
23
+ line-height: 24px;
24
+ text-transform: uppercase;
25
+ margin-bottom: 12px;
26
+ margin-top: 40px;
27
+ }
28
+
29
+ .link-list {
30
+ display: grid;
31
+ grid-template-columns: 1fr;
32
+ grid-template-rows: 1fr 1fr;
33
+ row-gap: 10px;
34
+ }
35
+
36
+ @media (min-width: 620px) {
37
+ .link-list {
38
+ row-gap: 20px;
39
+ column-gap: 20px;
40
+ grid-template-columns: 1fr 1fr;
41
+ }
42
+ }
43
+
44
+ @media all and (-ms-high-contrast:none) {
45
+ .link-list {
46
+ display: -ms-grid;
47
+ -ms-grid-columns: 1fr 1fr;
48
+ -ms-grid-rows: 1fr 1fr;
49
+ }
50
+ }
51
+
52
+ .link-item {
53
+ display: block;
54
+ padding: 20px 30px 20px 15px;
55
+ border: 1px solid #00000010;
56
+ border-radius: 5px;
57
+ transition: background 150ms ease-out, border 150ms ease-out, transform 150ms ease-out;
58
+ color: #333333;
59
+ display: flex;
60
+ align-items: flex-start;
61
+ }
62
+
63
+ .link-item:hover {
64
+ border-color: #1EA7FD50;
65
+ transform: translate3d(0, -3px, 0);
66
+ box-shadow: rgba(0, 0, 0, 0.08) 0 3px 10px 0;
67
+ }
68
+
69
+ .link-item:active {
70
+ border-color: #1EA7FD;
71
+ transform: translate3d(0, 0, 0);
72
+ }
73
+
74
+ .link-item strong {
75
+ font-weight: 700;
76
+ display: block;
77
+ margin-bottom: 2px;
78
+ }
79
+
80
+ .link-item-img-wrapper {
81
+ height: 40px;
82
+ width: 40px;
83
+ margin-right: 15px;
84
+ flex: none;
85
+ }
86
+
87
+ .link-item span {
88
+ font-size: 14px;
89
+ line-height: 20px;
90
+ }
91
+
92
+ .tip {
93
+ display: inline-block;
94
+ border-radius: 1em;
95
+ font-size: 11px;
96
+ line-height: 12px;
97
+ font-weight: 700;
98
+ background: #E7FDD8;
99
+ color: #66BF3C;
100
+ padding: 4px 12px;
101
+ margin-right: 10px;
102
+ vertical-align: top;
103
+ }
104
+
105
+ .tip-wrapper {
106
+ font-size: 13px;
107
+ line-height: 20px;
108
+ margin-top: 40px;
109
+ margin-bottom: 40px;
110
+ }
111
+
112
+ .tip-wrapper code {
113
+ font-size: 12px;
114
+ display: inline-block;
115
+ }
116
+ `}
117
+ </style>
118
+
119
+ # Welcome to Storybook
120
+
121
+ Storybook helps you build UI components in isolation from your app's business logic, data, and context.
122
+ That makes it easy to develop hard-to-reach states. Save these UI states as **stories** to revisit during development, testing, or QA.
123
+
124
+ Browse example stories now by navigating to them in the sidebar.
125
+ View their code in the `stories` directory to learn how they work.
126
+ We recommend building UIs with a [**component-driven**](https://componentdriven.org) process starting with atomic components and ending with pages.
127
+
128
+ <div className="subheading">Configure</div>
129
+
130
+ <div className="link-list">
131
+ <a
132
+ className="link-item"
133
+ href="https://storybook.js.org/docs/react/addons/addon-types"
134
+ target="_blank"
135
+ >
136
+ <div className="link-item-img-wrapper">
137
+ <Image src={Plugin} alt="plugin" />
138
+ </div>
139
+ <span>
140
+ <strong>Presets for popular tools</strong>
141
+ Easy setup for TypeScript, SCSS and more.
142
+ </span>
143
+ </a>
144
+ <a
145
+ className="link-item"
146
+ href="https://storybook.js.org/docs/react/configure/webpack"
147
+ target="_blank"
148
+ >
149
+ <div className="link-item-img-wrapper">
150
+ <Image src={StackAlt} alt="Build" />
151
+ </div>
152
+ <span>
153
+ <strong>Build configuration</strong>
154
+ How to customize webpack and Babel
155
+ </span>
156
+ </a>
157
+ <a
158
+ className="link-item"
159
+ href="https://storybook.js.org/docs/react/configure/styling-and-css"
160
+ target="_blank"
161
+ >
162
+ <div className="link-item-img-wrapper">
163
+ <Image src={Colors} alt="colors" />
164
+ </div>
165
+ <span>
166
+ <strong>Styling</strong>
167
+ How to load and configure CSS libraries
168
+ </span>
169
+ </a>
170
+ <a
171
+ className="link-item"
172
+ href="https://storybook.js.org/docs/react/get-started/setup#configure-storybook-for-your-stack"
173
+ target="_blank"
174
+ >
175
+ <div className="link-item-img-wrapper">
176
+ <Image src={Flow} alt="flow" />
177
+ </div>
178
+ <span>
179
+ <strong>Data</strong>
180
+ Providers and mocking for data libraries
181
+ </span>
182
+ </a>
183
+ </div>
184
+
185
+ <div className="subheading">Learn</div>
186
+
187
+ <div className="link-list">
188
+ <a className="link-item" href="https://storybook.js.org/docs" target="_blank">
189
+ <div className="link-item-img-wrapper">
190
+ <Image src={Repo} alt="repo" />
191
+ </div>
192
+ <span>
193
+ <strong>Storybook documentation</strong>
194
+ Configure, customize, and extend
195
+ </span>
196
+ </a>
197
+ <a className="link-item" href="https://storybook.js.org/tutorials/" target="_blank">
198
+ <div className="link-item-img-wrapper">
199
+ <Image src={Direction} alt="direction" />
200
+ </div>
201
+ <span>
202
+ <strong>In-depth guides</strong>
203
+ Best practices from leading teams
204
+ </span>
205
+ </a>
206
+ <a className="link-item" href="https://github.com/storybookjs/storybook" target="_blank">
207
+ <div className="link-item-img-wrapper">
208
+ <Image src={Code} alt="code" />
209
+ </div>
210
+ <span>
211
+ <strong>GitHub project</strong>
212
+ View the source and add issues
213
+ </span>
214
+ </a>
215
+ <a className="link-item" href="https://discord.gg/storybook" target="_blank">
216
+ <div className="link-item-img-wrapper">
217
+ <Image src={Comments} alt="comments" />
218
+ </div>
219
+ <span>
220
+ <strong>Discord chat</strong>
221
+ Chat with maintainers and the community
222
+ </span>
223
+ </a>
224
+ </div>
225
+
226
+ <div className="tip-wrapper">
227
+ <span className="tip">Tip</span>Edit the Markdown in <code>stories/Introduction.mdx</code>
228
+ </div>
@@ -0,0 +1,29 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { within, userEvent } from '@storybook/testing-library';
3
+
4
+ import { Page } from './Page';
5
+
6
+ const meta: Meta<typeof Page> = {
7
+ title: 'Example/Page',
8
+ component: Page,
9
+ parameters: {
10
+ // More on how to position stories at: https://storybook.js.org/docs/7.0/react/configure/story-layout
11
+ layout: 'fullscreen',
12
+ },
13
+ };
14
+
15
+ export default meta;
16
+ type Story = StoryObj<typeof Page>;
17
+
18
+ export const LoggedOut: Story = {};
19
+
20
+ // More on interaction testing: https://storybook.js.org/docs/7.0/react/writing-tests/interaction-testing
21
+ export const LoggedIn: Story = {
22
+ play: async ({ canvasElement }) => {
23
+ const canvas = within(canvasElement);
24
+ const loginButton = await canvas.getByRole('button', {
25
+ name: /Log in/i,
26
+ });
27
+ await userEvent.click(loginButton);
28
+ },
29
+ };
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+
3
+ import { Header } from './Header';
4
+ import './page.css';
5
+
6
+ type User = {
7
+ name: string;
8
+ };
9
+
10
+ export const Page: React.FC = () => {
11
+ const [user, setUser] = React.useState<User>();
12
+
13
+ return (
14
+ <article>
15
+ <Header
16
+ user={user}
17
+ onLogin={() => setUser({ name: 'Jane Doe' })}
18
+ onLogout={() => setUser(undefined)}
19
+ onCreateAccount={() => setUser({ name: 'Jane Doe' })}
20
+ />
21
+
22
+ <section>
23
+ <h2>Pages in Storybook</h2>
24
+ <p>
25
+ We recommend building UIs with a{' '}
26
+ <a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
27
+ <strong>component-driven</strong>
28
+ </a>{' '}
29
+ process starting with atomic components and ending with pages.
30
+ </p>
31
+ <p>
32
+ Render pages with mock data. This makes it easy to build and review page states without
33
+ needing to navigate to them in your app. Here are some handy patterns for managing page
34
+ data in Storybook:
35
+ </p>
36
+ <ul>
37
+ <li>
38
+ Use a higher-level connected component. Storybook helps you compose such data from the
39
+ "args" of child component stories
40
+ </li>
41
+ <li>
42
+ Assemble data in the page component from your services. You can mock these services out
43
+ using Storybook.
44
+ </li>
45
+ </ul>
46
+ <p>
47
+ Get a guided tutorial on component-driven development at{' '}
48
+ <a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
49
+ Storybook tutorials
50
+ </a>
51
+ . Read more in the{' '}
52
+ <a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">
53
+ docs
54
+ </a>
55
+ .
56
+ </p>
57
+ <div className="tip-wrapper">
58
+ <span className="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
+ );
73
+ };
@@ -224,5 +224,5 @@ We recommend building UIs with a [**component-driven**](https://componentdriven.
224
224
  </div>
225
225
 
226
226
  <div className="tip-wrapper">
227
- <span className="tip">Tip</span>Edit the Markdown in <code>stories/Introduction.stories.mdx</code>
227
+ <span className="tip">Tip</span>Edit the Markdown in <code>stories/Introduction.mdx</code>
228
228
  </div>