@storybook/nextjs-vite 0.0.0-pr-28800-sha-2528064a

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.
Files changed (54) hide show
  1. package/README.md +10 -0
  2. package/dist/chunk-4N4PSHX6.mjs +3 -0
  3. package/dist/chunk-5LLW2J7C.mjs +20 -0
  4. package/dist/chunk-GKRSUUNG.mjs +6 -0
  5. package/dist/export-mocks/cache/index.d.ts +14 -0
  6. package/dist/export-mocks/cache/index.js +1 -0
  7. package/dist/export-mocks/cache/index.mjs +6 -0
  8. package/dist/export-mocks/headers/index.d.ts +36 -0
  9. package/dist/export-mocks/headers/index.js +1 -0
  10. package/dist/export-mocks/headers/index.mjs +10 -0
  11. package/dist/export-mocks/navigation/index.d.ts +43 -0
  12. package/dist/export-mocks/navigation/index.js +1 -0
  13. package/dist/export-mocks/navigation/index.mjs +11 -0
  14. package/dist/export-mocks/router/index.d.ts +44 -0
  15. package/dist/export-mocks/router/index.js +1 -0
  16. package/dist/export-mocks/router/index.mjs +10 -0
  17. package/dist/images/decorator.d.ts +6 -0
  18. package/dist/images/decorator.js +1 -0
  19. package/dist/images/decorator.mjs +2 -0
  20. package/dist/index.d-e10eb603.d.ts +223 -0
  21. package/dist/index.d.ts +103 -0
  22. package/dist/index.js +1 -0
  23. package/dist/index.mjs +11 -0
  24. package/dist/preset.d.ts +8 -0
  25. package/dist/preset.js +1 -0
  26. package/dist/preview.d.ts +18 -0
  27. package/dist/preview.js +1 -0
  28. package/dist/preview.mjs +3 -0
  29. package/dist/react-18-WWEMNRVW.mjs +5 -0
  30. package/package.json +143 -0
  31. package/preset.js +1 -0
  32. package/template/cli/.eslintrc.json +7 -0
  33. package/template/cli/js/Button.jsx +54 -0
  34. package/template/cli/js/Button.stories.js +48 -0
  35. package/template/cli/js/Configure.mdx +446 -0
  36. package/template/cli/js/Header.jsx +59 -0
  37. package/template/cli/js/Header.stories.js +29 -0
  38. package/template/cli/js/Page.jsx +68 -0
  39. package/template/cli/js/Page.stories.js +27 -0
  40. package/template/cli/ts-3-8/Button.stories.ts +52 -0
  41. package/template/cli/ts-3-8/Button.tsx +52 -0
  42. package/template/cli/ts-3-8/Configure.mdx +446 -0
  43. package/template/cli/ts-3-8/Header.stories.ts +33 -0
  44. package/template/cli/ts-3-8/Header.tsx +56 -0
  45. package/template/cli/ts-3-8/Page.stories.ts +32 -0
  46. package/template/cli/ts-3-8/Page.tsx +73 -0
  47. package/template/cli/ts-4-9/Button.stories.ts +52 -0
  48. package/template/cli/ts-4-9/Button.tsx +52 -0
  49. package/template/cli/ts-4-9/Configure.mdx +446 -0
  50. package/template/cli/ts-4-9/Header.stories.ts +32 -0
  51. package/template/cli/ts-4-9/Header.tsx +56 -0
  52. package/template/cli/ts-4-9/Page.stories.ts +32 -0
  53. package/template/cli/ts-4-9/Page.tsx +73 -0
  54. package/template/next-env.d.ts +7 -0
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import { Button } from './Button';
5
+ import './header.css';
6
+
7
+ export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (
8
+ <header>
9
+ <div className="storybook-header">
10
+ <div>
11
+ <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
12
+ <g fill="none" fillRule="evenodd">
13
+ <path
14
+ d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
15
+ fill="#FFF"
16
+ />
17
+ <path
18
+ d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
19
+ fill="#555AB9"
20
+ />
21
+ <path
22
+ d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
23
+ fill="#91BAF8"
24
+ />
25
+ </g>
26
+ </svg>
27
+ <h1>Acme</h1>
28
+ </div>
29
+ <div>
30
+ {user ? (
31
+ <>
32
+ <span className="welcome">
33
+ Welcome, <b>{user.name}</b>!
34
+ </span>
35
+ <Button size="small" onClick={onLogout} label="Log out" />
36
+ </>
37
+ ) : (
38
+ <>
39
+ <Button size="small" onClick={onLogin} label="Log in" />
40
+ <Button primary size="small" onClick={onCreateAccount} label="Sign up" />
41
+ </>
42
+ )}
43
+ </div>
44
+ </div>
45
+ </header>
46
+ );
47
+
48
+ Header.propTypes = {
49
+ user: PropTypes.shape({
50
+ name: PropTypes.string.isRequired,
51
+ }),
52
+ onLogin: PropTypes.func.isRequired,
53
+ onLogout: PropTypes.func.isRequired,
54
+ onCreateAccount: PropTypes.func.isRequired,
55
+ };
56
+
57
+ Header.defaultProps = {
58
+ user: null,
59
+ };
@@ -0,0 +1,29 @@
1
+ import { fn } from '@storybook/test';
2
+ import { Header } from './Header';
3
+
4
+ export default {
5
+ title: 'Example/Header',
6
+ component: Header,
7
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
8
+ tags: ['autodocs'],
9
+ parameters: {
10
+ // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
11
+ layout: 'fullscreen',
12
+ },
13
+ args: {
14
+ onLogin: fn(),
15
+ onLogout: fn(),
16
+ onCreateAccount: fn(),
17
+ },
18
+ };
19
+ export const LoggedIn = {
20
+ args: {
21
+ user: {
22
+ name: 'Jane Doe',
23
+ },
24
+ },
25
+ };
26
+
27
+ export const LoggedOut = {
28
+ args: {},
29
+ };
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+
3
+ import { Header } from './Header';
4
+ import './page.css';
5
+
6
+ export const Page = () => {
7
+ const [user, setUser] = React.useState();
8
+
9
+ return (
10
+ <article>
11
+ <Header
12
+ user={user}
13
+ onLogin={() => setUser({ name: 'Jane Doe' })}
14
+ onLogout={() => setUser(undefined)}
15
+ onCreateAccount={() => setUser({ name: 'Jane Doe' })}
16
+ />
17
+ <section className="storybook-page">
18
+ <h2>Pages in Storybook</h2>
19
+ <p>
20
+ We recommend building UIs with a{' '}
21
+ <a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
22
+ <strong>component-driven</strong>
23
+ </a>{' '}
24
+ process starting with atomic components and ending with pages.
25
+ </p>
26
+ <p>
27
+ Render pages with mock data. This makes it easy to build and review page states without
28
+ needing to navigate to them in your app. Here are some handy patterns for managing page
29
+ data in Storybook:
30
+ </p>
31
+ <ul>
32
+ <li>
33
+ Use a higher-level connected component. Storybook helps you compose such data from the
34
+ "args" of child component stories
35
+ </li>
36
+ <li>
37
+ Assemble data in the page component from your services. You can mock these services out
38
+ using Storybook.
39
+ </li>
40
+ </ul>
41
+ <p>
42
+ Get a guided tutorial on component-driven development at{' '}
43
+ <a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
44
+ Storybook tutorials
45
+ </a>
46
+ . Read more in the{' '}
47
+ <a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">
48
+ docs
49
+ </a>
50
+ .
51
+ </p>
52
+ <div className="tip-wrapper">
53
+ <span className="tip">Tip</span> Adjust the width of the canvas with the{' '}
54
+ <svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
55
+ <g fill="none" fillRule="evenodd">
56
+ <path
57
+ 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"
58
+ id="a"
59
+ fill="#999"
60
+ />
61
+ </g>
62
+ </svg>
63
+ Viewports addon in the toolbar
64
+ </div>
65
+ </section>
66
+ </article>
67
+ );
68
+ };
@@ -0,0 +1,27 @@
1
+ import { within, userEvent, expect } from '@storybook/test';
2
+ import { Page } from './Page';
3
+
4
+ export default {
5
+ title: 'Example/Page',
6
+ component: Page,
7
+ parameters: {
8
+ // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
9
+ layout: 'fullscreen',
10
+ },
11
+ };
12
+
13
+ export const LoggedOut = {};
14
+
15
+ // More on interaction testing: https://storybook.js.org/docs/writing-tests/interaction-testing
16
+ export const LoggedIn = {
17
+ play: async ({ canvasElement }) => {
18
+ const canvas = within(canvasElement);
19
+ const loginButton = canvas.getByRole('button', { name: /Log in/i });
20
+ await expect(loginButton).toBeInTheDocument();
21
+ await userEvent.click(loginButton);
22
+ await expect(loginButton).not.toBeInTheDocument();
23
+
24
+ const logoutButton = canvas.getByRole('button', { name: /Log out/i });
25
+ await expect(logoutButton).toBeInTheDocument();
26
+ },
27
+ };
@@ -0,0 +1,52 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { fn } from '@storybook/test';
3
+ import { Button } from './Button';
4
+
5
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
6
+ const meta: Meta<typeof Button> = {
7
+ title: 'Example/Button',
8
+ component: Button,
9
+ parameters: {
10
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
11
+ layout: 'centered',
12
+ },
13
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
14
+ tags: ['autodocs'],
15
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
16
+ argTypes: {
17
+ backgroundColor: { control: 'color' },
18
+ },
19
+ // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
20
+ args: { onClick: fn() },
21
+ };
22
+
23
+ export default meta;
24
+ type Story = StoryObj<typeof Button>;
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,52 @@
1
+ import React from 'react';
2
+ import './button.css';
3
+
4
+ export 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
+ };