@storybook/experimental-nextjs-vite 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/dist/{chunk-PIRL4JPH.mjs → chunk-3Z6MACOM.mjs} +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +3 -3
- package/dist/preview.js +1 -1
- package/dist/preview.mjs +1 -1
- package/package.json +7 -7
- package/template/cli/ts-3-8/Button.stories.ts +0 -53
- package/template/cli/ts-3-8/Button.tsx +0 -41
- package/template/cli/ts-3-8/Configure.mdx +0 -446
- package/template/cli/ts-3-8/Header.stories.ts +0 -33
- package/template/cli/ts-3-8/Header.tsx +0 -56
- package/template/cli/ts-3-8/Page.stories.ts +0 -32
- package/template/cli/ts-3-8/Page.tsx +0 -73
package/dist/preview.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var preview_exports={};__export(preview_exports,{decorators:()=>decorators,loaders:()=>loaders,parameters:()=>parameters});module.exports=__toCommonJS(preview_exports);var import_navigation2=require("@storybook/experimental-nextjs-vite/navigation.mock"),import_router2=require("@storybook/experimental-nextjs-vite/router.mock"),import_is_next_router_error=require("next/dist/client/components/is-next-router-error");var import_config=require("next/config");(0,import_config.setConfig)(process.env.__NEXT_RUNTIME_CONFIG);var React2=__toESM(require("react"));var import_react=__toESM(require("react")),import_head_manager=__toESM(require("next/dist/client/head-manager")),import_head_manager_context=require("next/dist/shared/lib/head-manager-context.shared-runtime"),HeadManagerProvider=({children})=>{let headManager=(0,import_react.useMemo)(import_head_manager.default,[]);return headManager.getIsSsr=()=>!1,import_react.default.createElement(import_head_manager_context.HeadManagerContext.Provider,{value:headManager},children)},head_manager_provider_default=HeadManagerProvider;var HeadManagerDecorator=Story=>React2.createElement(head_manager_provider_default,null,React2.createElement(Story,null));var React3=__toESM(require("react")),import_image_context=require("sb-original/image-context"),ImageDecorator=(Story,{parameters:parameters2})=>parameters2.nextjs?.image?React3.createElement(import_image_context.ImageContext.Provider,{value:parameters2.nextjs.image},React3.createElement(Story,null)):React3.createElement(Story,null);var React6=__toESM(require("react")),import_redirect_boundary=require("next/dist/client/components/redirect-boundary");var import_react2=__toESM(require("react")),import_navigation=require("@storybook/experimental-nextjs-vite/navigation.mock"),import_app_router_context=require("next/dist/shared/lib/app-router-context.shared-runtime"),import_hooks_client_context=require("next/dist/shared/lib/hooks-client-context.shared-runtime"),import_segment=require("next/dist/shared/lib/segment");function getSelectedParams(currentTree,params={}){let parallelRoutes=currentTree[1];for(let parallelRoute of Object.values(parallelRoutes)){let segment=parallelRoute[0],isDynamicParameter=Array.isArray(segment),segmentValue=isDynamicParameter?segment[1]:segment;if(!segmentValue||segmentValue.startsWith(import_segment.PAGE_SEGMENT_KEY))continue;isDynamicParameter&&(segment[2]==="c"||segment[2]==="oc")?params[segment[0]]=segment[1].split("/"):isDynamicParameter&&(params[segment[0]]=segment[1]),params=getSelectedParams(parallelRoute,params)}return params}var getParallelRoutes=segmentsList=>{let segment=segmentsList.shift();return segment?[segment,{children:getParallelRoutes(segmentsList)}]:[]},AppRouterProvider=({children,routeParams})=>{let{pathname,query,segments=[]}=routeParams,tree=[pathname,{children:getParallelRoutes([...segments])}],pathParams=(0,import_react2.useMemo)(()=>getSelectedParams(tree),[tree]),newLazyCacheNode={lazyData:null,rsc:null,prefetchRsc:null,head:null,prefetchHead:null,parallelRoutes:new Map,loading:null};return import_react2.default.createElement(import_hooks_client_context.PathParamsContext.Provider,{value:pathParams},import_react2.default.createElement(import_hooks_client_context.PathnameContext.Provider,{value:pathname},import_react2.default.createElement(import_hooks_client_context.SearchParamsContext.Provider,{value:new URLSearchParams(query)},import_react2.default.createElement(import_app_router_context.GlobalLayoutRouterContext.Provider,{value:{changeByServerResponse(){},buildId:"storybook",tree,focusAndScrollRef:{apply:!1,hashFragment:null,segmentPaths:[tree],onlyHashChange:!1},nextUrl:pathname}},import_react2.default.createElement(import_app_router_context.AppRouterContext.Provider,{value:(0,import_navigation.getRouter)()},import_react2.default.createElement(import_app_router_context.LayoutRouterContext.Provider,{value:{childNodes:new Map,tree,parentTree:tree,parentCacheNode:newLazyCacheNode,url:pathname,loading:null}},children))))))};var import_react3=__toESM(require("react")),import_router=require("@storybook/experimental-nextjs-vite/router.mock"),import_router_context=require("next/dist/shared/lib/router-context.shared-runtime"),PageRouterProvider=({children})=>import_react3.default.createElement(import_router_context.RouterContext.Provider,{value:(0,import_router.getRouter)()},children);var defaultRouterParams={pathname:"/",query:{}},RouterDecorator=(Story,{parameters:parameters2})=>parameters2.nextjs?.appDirectory??!1?AppRouterProvider?React6.createElement(AppRouterProvider,{routeParams:{...defaultRouterParams,...parameters2.nextjs?.navigation}},React6.createElement(import_redirect_boundary.RedirectBoundary,null,React6.createElement(Story,null))):null:React6.createElement(PageRouterProvider,null,React6.createElement(Story,null));var React7=__toESM(require("react")),import_styled_jsx=require("styled-jsx"),StyledJsxDecorator=Story=>React7.createElement(import_styled_jsx.StyleRegistry,null,React7.createElement(Story,null));function addNextHeadCount(){let meta=document.createElement("meta");meta.name="next-head-count",meta.content="0",document.head.appendChild(meta)}function isAsyncClientComponentError(error){return typeof error=="string"&&(error.includes("A component was suspended by an uncached promise.")||error.includes("async/await is not yet supported in Client Components"))}addNextHeadCount();var origConsoleError=globalThis.console.error;globalThis.console.error=(...args)=>{let error=args[0];(0,import_is_next_router_error.isNextRouterError)(error)||isAsyncClientComponentError(error)||origConsoleError.apply(globalThis.console,args)};globalThis.addEventListener("error",ev=>{if((0,import_is_next_router_error.isNextRouterError)(ev.error)||isAsyncClientComponentError(ev.error)){ev.preventDefault();return}});var decorators=[StyledJsxDecorator,ImageDecorator,RouterDecorator,HeadManagerDecorator],loaders=async({globals,parameters:parameters2})=>{let{router,appDirectory}=parameters2.nextjs??{};appDirectory?(0,import_navigation2.createNavigation)(router):(0,import_router2.createRouter)({locale:globals.locale,...router})},parameters={docs:{source:{excludeDecorators:!0}},react:{rootOptions:{onCaughtError(error){(0,import_is_next_router_error.isNextRouterError)(error)||console.error(error)}}}};0&&(module.exports={decorators,loaders,parameters});
|
1
|
+
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var preview_exports={};__export(preview_exports,{decorators:()=>decorators,loaders:()=>loaders,parameters:()=>parameters});module.exports=__toCommonJS(preview_exports);var import_navigation2=require("@storybook/experimental-nextjs-vite/navigation.mock"),import_router2=require("@storybook/experimental-nextjs-vite/router.mock"),import_is_next_router_error=require("next/dist/client/components/is-next-router-error");var import_config=require("next/config");(0,import_config.setConfig)(process.env.__NEXT_RUNTIME_CONFIG);var React2=__toESM(require("react"));var import_react=__toESM(require("react")),import_head_manager=__toESM(require("next/dist/client/head-manager")),import_head_manager_context=require("next/dist/shared/lib/head-manager-context.shared-runtime"),HeadManagerProvider=({children})=>{let headManager=(0,import_react.useMemo)(import_head_manager.default,[]);return headManager.getIsSsr=()=>!1,import_react.default.createElement(import_head_manager_context.HeadManagerContext.Provider,{value:headManager},children)},head_manager_provider_default=HeadManagerProvider;var HeadManagerDecorator=Story=>React2.createElement(head_manager_provider_default,null,React2.createElement(Story,null));var React3=__toESM(require("react")),import_image_context=require("sb-original/image-context"),ImageDecorator=(Story,{parameters:parameters2})=>parameters2.nextjs?.image?React3.createElement(import_image_context.ImageContext.Provider,{value:parameters2.nextjs.image},React3.createElement(Story,null)):React3.createElement(Story,null);var React6=__toESM(require("react")),import_redirect_boundary=require("next/dist/client/components/redirect-boundary");var import_react2=__toESM(require("react")),import_navigation=require("@storybook/experimental-nextjs-vite/navigation.mock"),import_app_router_context=require("next/dist/shared/lib/app-router-context.shared-runtime"),import_hooks_client_context=require("next/dist/shared/lib/hooks-client-context.shared-runtime"),import_segment=require("next/dist/shared/lib/segment");function getSelectedParams(currentTree,params={}){let parallelRoutes=currentTree[1];for(let parallelRoute of Object.values(parallelRoutes)){let segment=parallelRoute[0],isDynamicParameter=Array.isArray(segment),segmentValue=isDynamicParameter?segment[1]:segment;if(!segmentValue||segmentValue.startsWith(import_segment.PAGE_SEGMENT_KEY))continue;isDynamicParameter&&(segment[2]==="c"||segment[2]==="oc")?params[segment[0]]=segment[1].split("/"):isDynamicParameter&&(params[segment[0]]=segment[1]),params=getSelectedParams(parallelRoute,params)}return params}var getParallelRoutes=segmentsList=>{let segment=segmentsList.shift();return segment?[segment,{children:getParallelRoutes(segmentsList)}]:[]},AppRouterProvider=({children,routeParams})=>{let{pathname,query,segments=[]}=routeParams,tree=[pathname,{children:getParallelRoutes([...segments])}],pathParams=(0,import_react2.useMemo)(()=>getSelectedParams(tree),[tree]),newLazyCacheNode={lazyData:null,rsc:null,prefetchRsc:null,head:null,prefetchHead:null,parallelRoutes:new Map,loading:null};return import_react2.default.createElement(import_hooks_client_context.PathParamsContext.Provider,{value:pathParams},import_react2.default.createElement(import_hooks_client_context.PathnameContext.Provider,{value:pathname},import_react2.default.createElement(import_hooks_client_context.SearchParamsContext.Provider,{value:new URLSearchParams(query)},import_react2.default.createElement(import_app_router_context.GlobalLayoutRouterContext.Provider,{value:{changeByServerResponse(){},buildId:"storybook",tree,focusAndScrollRef:{apply:!1,hashFragment:null,segmentPaths:[tree],onlyHashChange:!1},nextUrl:pathname}},import_react2.default.createElement(import_app_router_context.AppRouterContext.Provider,{value:(0,import_navigation.getRouter)()},import_react2.default.createElement(import_app_router_context.LayoutRouterContext.Provider,{value:{childNodes:new Map,tree,parentTree:tree,parentCacheNode:newLazyCacheNode,url:pathname,loading:null}},children))))))};var import_react3=__toESM(require("react")),import_router=require("@storybook/experimental-nextjs-vite/router.mock"),import_router_context=require("next/dist/shared/lib/router-context.shared-runtime"),PageRouterProvider=({children})=>import_react3.default.createElement(import_router_context.RouterContext.Provider,{value:(0,import_router.getRouter)()},children);var defaultRouterParams={pathname:"/",query:{}},RouterDecorator=(Story,{parameters:parameters2})=>parameters2.nextjs?.appDirectory??!1?AppRouterProvider?React6.createElement(AppRouterProvider,{routeParams:{...defaultRouterParams,...parameters2.nextjs?.navigation}},React6.createElement(import_redirect_boundary.RedirectBoundary,null,React6.createElement(Story,null))):null:React6.createElement(PageRouterProvider,null,React6.createElement(Story,null));var React7=__toESM(require("react")),import_styled_jsx=require("styled-jsx"),StyledJsxDecorator=Story=>React7.createElement(import_styled_jsx.StyleRegistry,null,React7.createElement(Story,null));function addNextHeadCount(){let meta=document.createElement("meta");meta.name="next-head-count",meta.content="0",document.head.appendChild(meta)}function isAsyncClientComponentError(error){return typeof error=="string"&&(error.includes("Only Server Components can be async at the moment.")||error.includes("A component was suspended by an uncached promise.")||error.includes("async/await is not yet supported in Client Components"))}addNextHeadCount();var origConsoleError=globalThis.console.error;globalThis.console.error=(...args)=>{let error=args[0];(0,import_is_next_router_error.isNextRouterError)(error)||isAsyncClientComponentError(error)||origConsoleError.apply(globalThis.console,args)};globalThis.addEventListener("error",ev=>{if((0,import_is_next_router_error.isNextRouterError)(ev.error)||isAsyncClientComponentError(ev.error)){ev.preventDefault();return}});var decorators=[StyledJsxDecorator,ImageDecorator,RouterDecorator,HeadManagerDecorator],loaders=async({globals,parameters:parameters2})=>{let{router,appDirectory}=parameters2.nextjs??{};appDirectory?(0,import_navigation2.createNavigation)(router):(0,import_router2.createRouter)({locale:globals.locale,...router})},parameters={docs:{source:{excludeDecorators:!0}},react:{rootOptions:{onCaughtError(error){(0,import_is_next_router_error.isNextRouterError)(error)||console.error(error)}}}};0&&(module.exports={decorators,loaders,parameters});
|
package/dist/preview.mjs
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storybook/experimental-nextjs-vite",
|
3
|
-
"version": "9.0.0-alpha.
|
3
|
+
"version": "9.0.0-alpha.2",
|
4
4
|
"description": "Storybook for Next.js and Vite",
|
5
5
|
"keywords": [
|
6
6
|
"storybook",
|
@@ -104,10 +104,10 @@
|
|
104
104
|
"prep": "jiti ../../../scripts/prepare/bundle.ts"
|
105
105
|
},
|
106
106
|
"dependencies": {
|
107
|
-
"@storybook/builder-vite": "9.0.0-alpha.
|
108
|
-
"@storybook/react": "9.0.0-alpha.
|
109
|
-
"@storybook/react-vite": "9.0.0-alpha.
|
110
|
-
"@storybook/test": "9.0.0-alpha.
|
107
|
+
"@storybook/builder-vite": "9.0.0-alpha.2",
|
108
|
+
"@storybook/react": "9.0.0-alpha.2",
|
109
|
+
"@storybook/react-vite": "9.0.0-alpha.2",
|
110
|
+
"@storybook/test": "9.0.0-alpha.2",
|
111
111
|
"styled-jsx": "5.1.6",
|
112
112
|
"vite-plugin-storybook-nextjs": "^1.1.0"
|
113
113
|
},
|
@@ -117,11 +117,11 @@
|
|
117
117
|
"typescript": "^5.7.3"
|
118
118
|
},
|
119
119
|
"peerDependencies": {
|
120
|
-
"@storybook/test": "9.0.0-alpha.
|
120
|
+
"@storybook/test": "9.0.0-alpha.2",
|
121
121
|
"next": "^14.1.0 || ^15.0.0",
|
122
122
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
|
123
123
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
|
124
|
-
"storybook": "^9.0.0-alpha.
|
124
|
+
"storybook": "^9.0.0-alpha.2",
|
125
125
|
"vite": "^5.0.0 || ^6.0.0"
|
126
126
|
},
|
127
127
|
"peerDependenciesMeta": {
|
@@ -1,53 +0,0 @@
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
2
|
-
import { fn } from '@storybook/test';
|
3
|
-
|
4
|
-
import { Button } from './Button';
|
5
|
-
|
6
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
7
|
-
const meta: Meta<typeof Button> = {
|
8
|
-
title: 'Example/Button',
|
9
|
-
component: Button,
|
10
|
-
parameters: {
|
11
|
-
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
12
|
-
layout: 'centered',
|
13
|
-
},
|
14
|
-
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
15
|
-
tags: ['autodocs'],
|
16
|
-
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
17
|
-
argTypes: {
|
18
|
-
backgroundColor: { control: 'color' },
|
19
|
-
},
|
20
|
-
// 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
|
21
|
-
args: { onClick: fn() },
|
22
|
-
};
|
23
|
-
|
24
|
-
export default meta;
|
25
|
-
type Story = StoryObj<typeof Button>;
|
26
|
-
|
27
|
-
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
28
|
-
export const Primary: Story = {
|
29
|
-
args: {
|
30
|
-
primary: true,
|
31
|
-
label: 'Button',
|
32
|
-
},
|
33
|
-
};
|
34
|
-
|
35
|
-
export const Secondary: Story = {
|
36
|
-
args: {
|
37
|
-
label: 'Button',
|
38
|
-
},
|
39
|
-
};
|
40
|
-
|
41
|
-
export const Large: Story = {
|
42
|
-
args: {
|
43
|
-
size: 'large',
|
44
|
-
label: 'Button',
|
45
|
-
},
|
46
|
-
};
|
47
|
-
|
48
|
-
export const Small: Story = {
|
49
|
-
args: {
|
50
|
-
size: 'small',
|
51
|
-
label: 'Button',
|
52
|
-
},
|
53
|
-
};
|
@@ -1,41 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
|
3
|
-
import './button.css';
|
4
|
-
|
5
|
-
export interface ButtonProps {
|
6
|
-
/** Is this the principal call to action on the page? */
|
7
|
-
primary?: boolean;
|
8
|
-
/** What background color to use */
|
9
|
-
backgroundColor?: string;
|
10
|
-
/** How large should the button be? */
|
11
|
-
size?: 'small' | 'medium' | 'large';
|
12
|
-
/** Button contents */
|
13
|
-
label: string;
|
14
|
-
/** Optional click handler */
|
15
|
-
onClick?: () => void;
|
16
|
-
}
|
17
|
-
|
18
|
-
/** Primary UI component for user interaction */
|
19
|
-
export const Button = ({
|
20
|
-
primary = false,
|
21
|
-
size = 'medium',
|
22
|
-
backgroundColor,
|
23
|
-
label,
|
24
|
-
...props
|
25
|
-
}: ButtonProps) => {
|
26
|
-
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
27
|
-
return (
|
28
|
-
<button
|
29
|
-
type="button"
|
30
|
-
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
31
|
-
{...props}
|
32
|
-
>
|
33
|
-
{label}
|
34
|
-
<style jsx>{`
|
35
|
-
button {
|
36
|
-
background-color: ${backgroundColor};
|
37
|
-
}
|
38
|
-
`}</style>
|
39
|
-
</button>
|
40
|
-
);
|
41
|
-
};
|
@@ -1,446 +0,0 @@
|
|
1
|
-
import { Meta } from "@storybook/blocks";
|
2
|
-
import Image from "next/image";
|
3
|
-
|
4
|
-
import Github from "./assets/github.svg";
|
5
|
-
import Discord from "./assets/discord.svg";
|
6
|
-
import Youtube from "./assets/youtube.svg";
|
7
|
-
import Tutorials from "./assets/tutorials.svg";
|
8
|
-
import Styling from "./assets/styling.png";
|
9
|
-
import Context from "./assets/context.png";
|
10
|
-
import Assets from "./assets/assets.png";
|
11
|
-
import Docs from "./assets/docs.png";
|
12
|
-
import Share from "./assets/share.png";
|
13
|
-
import FigmaPlugin from "./assets/figma-plugin.png";
|
14
|
-
import Testing from "./assets/testing.png";
|
15
|
-
import Accessibility from "./assets/accessibility.png";
|
16
|
-
import Theming from "./assets/theming.png";
|
17
|
-
import AddonLibrary from "./assets/addon-library.png";
|
18
|
-
|
19
|
-
export const RightArrow = () => <svg
|
20
|
-
viewBox="0 0 14 14"
|
21
|
-
width="8px"
|
22
|
-
height="14px"
|
23
|
-
style={{
|
24
|
-
marginLeft: '4px',
|
25
|
-
display: 'inline-block',
|
26
|
-
shapeRendering: 'inherit',
|
27
|
-
verticalAlign: 'middle',
|
28
|
-
fill: 'currentColor',
|
29
|
-
'path fill': 'currentColor'
|
30
|
-
}}
|
31
|
-
>
|
32
|
-
<path d="m11.1 7.35-5.5 5.5a.5.5 0 0 1-.7-.7L10.04 7 4.9 1.85a.5.5 0 1 1 .7-.7l5.5 5.5c.2.2.2.5 0 .7Z" />
|
33
|
-
</svg>
|
34
|
-
|
35
|
-
<Meta title="Configure your project" />
|
36
|
-
|
37
|
-
<div className="sb-container">
|
38
|
-
<div className='sb-section-title'>
|
39
|
-
# Configure your project
|
40
|
-
|
41
|
-
Because Storybook works separately from your app, you'll need to configure it for your specific stack and setup. Below, explore guides for configuring Storybook with popular frameworks and tools. If you get stuck, learn how you can ask for help from our community.
|
42
|
-
</div>
|
43
|
-
<div className="sb-section">
|
44
|
-
<div className="sb-section-item">
|
45
|
-
<Image
|
46
|
-
src={Styling}
|
47
|
-
alt="A wall of logos representing different styling technologies"
|
48
|
-
width={0}
|
49
|
-
height={0}
|
50
|
-
style={{ width: '100%', height: 'auto' }}
|
51
|
-
/>
|
52
|
-
<h4 className="sb-section-item-heading">Add styling and CSS</h4>
|
53
|
-
<p className="sb-section-item-paragraph">Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.</p>
|
54
|
-
<a
|
55
|
-
href="https://storybook.js.org/docs/configure/styling-and-css/?renderer=react"
|
56
|
-
target="_blank"
|
57
|
-
>Learn more<RightArrow /></a>
|
58
|
-
</div>
|
59
|
-
<div className="sb-section-item">
|
60
|
-
<Image
|
61
|
-
width={0}
|
62
|
-
height={0}
|
63
|
-
style={{ width: '100%', height: 'auto' }}
|
64
|
-
src={Context}
|
65
|
-
alt="An abstraction representing the composition of data for a component"
|
66
|
-
/>
|
67
|
-
<h4 className="sb-section-item-heading">Provide context and mocking</h4>
|
68
|
-
<p className="sb-section-item-paragraph">Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.</p>
|
69
|
-
<a
|
70
|
-
href="https://storybook.js.org/docs/writing-stories/decorators/?renderer=react#context-for-mocking"
|
71
|
-
target="_blank"
|
72
|
-
>Learn more<RightArrow /></a>
|
73
|
-
</div>
|
74
|
-
<div className="sb-section-item">
|
75
|
-
<Image
|
76
|
-
width={0}
|
77
|
-
height={0}
|
78
|
-
style={{ width: '100%', height: 'auto' }}
|
79
|
-
src={Assets}
|
80
|
-
alt="A representation of typography and image assets"
|
81
|
-
/>
|
82
|
-
<div>
|
83
|
-
<h4 className="sb-section-item-heading">Load assets and resources</h4>
|
84
|
-
<p className="sb-section-item-paragraph">To link static files (like fonts) to your projects and stories, use the
|
85
|
-
`staticDirs` configuration option to specify folders to load when
|
86
|
-
starting Storybook.</p>
|
87
|
-
<a
|
88
|
-
href="https://storybook.js.org/docs/configure/images-and-assets/?renderer=react"
|
89
|
-
target="_blank"
|
90
|
-
>Learn more<RightArrow /></a>
|
91
|
-
</div>
|
92
|
-
</div>
|
93
|
-
</div>
|
94
|
-
</div>
|
95
|
-
<div className="sb-container">
|
96
|
-
<div className='sb-section-title'>
|
97
|
-
# Do more with Storybook
|
98
|
-
|
99
|
-
Now that you know the basics, let's explore other parts of Storybook that will improve your experience. This list is just to get you started. You can customise Storybook in many ways to fit your needs.
|
100
|
-
</div>
|
101
|
-
|
102
|
-
<div className="sb-section">
|
103
|
-
<div className="sb-features-grid">
|
104
|
-
<div className="sb-grid-item">
|
105
|
-
<Image
|
106
|
-
width={0}
|
107
|
-
height={0}
|
108
|
-
style={{ width: '100%', height: 'auto' }}
|
109
|
-
src={Docs}
|
110
|
-
alt="A screenshot showing the autodocs tag being set, pointing a docs page being generated"
|
111
|
-
/>
|
112
|
-
<h4 className="sb-section-item-heading">Autodocs</h4>
|
113
|
-
<p className="sb-section-item-paragraph">Auto-generate living,
|
114
|
-
interactive reference documentation from your components and stories.</p>
|
115
|
-
<a
|
116
|
-
href="https://storybook.js.org/docs/writing-docs/autodocs/?renderer=react"
|
117
|
-
target="_blank"
|
118
|
-
>Learn more<RightArrow /></a>
|
119
|
-
</div>
|
120
|
-
<div className="sb-grid-item">
|
121
|
-
<Image
|
122
|
-
width={0}
|
123
|
-
height={0}
|
124
|
-
style={{ width: '100%', height: 'auto' }}
|
125
|
-
src={Share}
|
126
|
-
alt="A browser window showing a Storybook being published to a chromatic.com URL"
|
127
|
-
/>
|
128
|
-
<h4 className="sb-section-item-heading">Publish to Chromatic</h4>
|
129
|
-
<p className="sb-section-item-paragraph">Publish your Storybook to review and collaborate with your entire team.</p>
|
130
|
-
<a
|
131
|
-
href="https://storybook.js.org/docs/sharing/publish-storybook/?renderer=react#publish-storybook-with-chromatic"
|
132
|
-
target="_blank"
|
133
|
-
>Learn more<RightArrow /></a>
|
134
|
-
</div>
|
135
|
-
<div className="sb-grid-item">
|
136
|
-
<Image
|
137
|
-
width={0}
|
138
|
-
height={0}
|
139
|
-
style={{ width: '100%', height: 'auto' }}
|
140
|
-
src={FigmaPlugin}
|
141
|
-
alt="Windows showing the Storybook plugin in Figma"
|
142
|
-
/>
|
143
|
-
<h4 className="sb-section-item-heading">Figma Plugin</h4>
|
144
|
-
<p className="sb-section-item-paragraph">Embed your stories into Figma to cross-reference the design and live
|
145
|
-
implementation in one place.</p>
|
146
|
-
<a
|
147
|
-
href="https://storybook.js.org/docs/sharing/design-integrations/?renderer=react#embed-storybook-in-figma-with-the-plugin"
|
148
|
-
target="_blank"
|
149
|
-
>Learn more<RightArrow /></a>
|
150
|
-
</div>
|
151
|
-
<div className="sb-grid-item">
|
152
|
-
<Image
|
153
|
-
width={0}
|
154
|
-
height={0}
|
155
|
-
style={{ width: '100%', height: 'auto' }}
|
156
|
-
src={Testing}
|
157
|
-
alt="Screenshot of tests passing and failing"
|
158
|
-
/>
|
159
|
-
<h4 className="sb-section-item-heading">Testing</h4>
|
160
|
-
<p className="sb-section-item-paragraph">Use stories to test a component in all its variations, no matter how
|
161
|
-
complex.</p>
|
162
|
-
<a
|
163
|
-
href="https://storybook.js.org/docs/writing-tests/?renderer=react"
|
164
|
-
target="_blank"
|
165
|
-
>Learn more<RightArrow /></a>
|
166
|
-
</div>
|
167
|
-
<div className="sb-grid-item">
|
168
|
-
<Image
|
169
|
-
width={0}
|
170
|
-
height={0}
|
171
|
-
style={{ width: '100%', height: 'auto' }}
|
172
|
-
src={Accessibility}
|
173
|
-
alt="Screenshot of accessibility tests passing and failing"
|
174
|
-
/>
|
175
|
-
<h4 className="sb-section-item-heading">Accessibility</h4>
|
176
|
-
<p className="sb-section-item-paragraph">Automatically test your components for a11y issues as you develop.</p>
|
177
|
-
<a
|
178
|
-
href="https://storybook.js.org/docs/writing-tests/accessibility-testing/?renderer=react"
|
179
|
-
target="_blank"
|
180
|
-
>Learn more<RightArrow /></a>
|
181
|
-
</div>
|
182
|
-
<div className="sb-grid-item">
|
183
|
-
<Image
|
184
|
-
width={0}
|
185
|
-
height={0}
|
186
|
-
style={{ width: '100%', height: 'auto' }}
|
187
|
-
src={Theming}
|
188
|
-
alt="Screenshot of Storybook in light and dark mode"
|
189
|
-
/>
|
190
|
-
<h4 className="sb-section-item-heading">Theming</h4>
|
191
|
-
<p className="sb-section-item-paragraph">Theme Storybook's UI to personalize it to your project.</p>
|
192
|
-
<a
|
193
|
-
href="https://storybook.js.org/docs/configure/theming/?renderer=react"
|
194
|
-
target="_blank"
|
195
|
-
>Learn more<RightArrow /></a>
|
196
|
-
</div>
|
197
|
-
</div>
|
198
|
-
</div>
|
199
|
-
</div>
|
200
|
-
<div className='sb-addon'>
|
201
|
-
<div className='sb-addon-text'>
|
202
|
-
<h4>Addons</h4>
|
203
|
-
<p className="sb-section-item-paragraph">Integrate your tools with Storybook to connect workflows.</p>
|
204
|
-
<a
|
205
|
-
href="https://storybook.js.org/addons/"
|
206
|
-
target="_blank"
|
207
|
-
>Discover all addons<RightArrow /></a>
|
208
|
-
</div>
|
209
|
-
<div className='sb-addon-img'>
|
210
|
-
<Image
|
211
|
-
width={650}
|
212
|
-
height={347}
|
213
|
-
src={AddonLibrary}
|
214
|
-
alt="Integrate your tools with Storybook to connect workflows."
|
215
|
-
/>
|
216
|
-
</div>
|
217
|
-
</div>
|
218
|
-
|
219
|
-
<div className="sb-section sb-socials">
|
220
|
-
<div className="sb-section-item">
|
221
|
-
<Image
|
222
|
-
width={32}
|
223
|
-
height={32}
|
224
|
-
layout="fixed"
|
225
|
-
src={Github}
|
226
|
-
alt="Github logo"
|
227
|
-
className="sb-explore-image"
|
228
|
-
/>
|
229
|
-
Join our contributors building the future of UI development.
|
230
|
-
|
231
|
-
<a
|
232
|
-
href="https://github.com/storybookjs/storybook"
|
233
|
-
target="_blank"
|
234
|
-
>Star on GitHub<RightArrow /></a>
|
235
|
-
</div>
|
236
|
-
<div className="sb-section-item">
|
237
|
-
<Image
|
238
|
-
width={33}
|
239
|
-
height={32}
|
240
|
-
layout="fixed"
|
241
|
-
src={Discord}
|
242
|
-
alt="Discord logo"
|
243
|
-
className="sb-explore-image"
|
244
|
-
/>
|
245
|
-
<div>
|
246
|
-
Get support and chat with frontend developers.
|
247
|
-
|
248
|
-
<a
|
249
|
-
href="https://discord.gg/storybook"
|
250
|
-
target="_blank"
|
251
|
-
>Join Discord server<RightArrow /></a>
|
252
|
-
</div>
|
253
|
-
</div>
|
254
|
-
<div className="sb-section-item">
|
255
|
-
<Image
|
256
|
-
width={32}
|
257
|
-
height={32}
|
258
|
-
layout="fixed"
|
259
|
-
src={Youtube}
|
260
|
-
alt="Youtube logo"
|
261
|
-
className="sb-explore-image"
|
262
|
-
/>
|
263
|
-
<div>
|
264
|
-
Watch tutorials, feature previews and interviews.
|
265
|
-
|
266
|
-
<a
|
267
|
-
href="https://www.youtube.com/@chromaticui"
|
268
|
-
target="_blank"
|
269
|
-
>Watch on YouTube<RightArrow /></a>
|
270
|
-
</div>
|
271
|
-
</div>
|
272
|
-
<div className="sb-section-item">
|
273
|
-
<Image
|
274
|
-
width={33}
|
275
|
-
height={32}
|
276
|
-
layout="fixed"
|
277
|
-
src={Tutorials}
|
278
|
-
alt="A book"
|
279
|
-
className="sb-explore-image"
|
280
|
-
/>
|
281
|
-
<p>Follow guided walkthroughs on for key workflows.</p>
|
282
|
-
|
283
|
-
<a
|
284
|
-
href="https://storybook.js.org/tutorials/"
|
285
|
-
target="_blank"
|
286
|
-
>Discover tutorials<RightArrow /></a>
|
287
|
-
</div>
|
288
|
-
</div>
|
289
|
-
|
290
|
-
<style>
|
291
|
-
{`
|
292
|
-
.sb-container {
|
293
|
-
margin-bottom: 48px;
|
294
|
-
}
|
295
|
-
|
296
|
-
.sb-section {
|
297
|
-
width: 100%;
|
298
|
-
display: flex;
|
299
|
-
flex-direction: row;
|
300
|
-
gap: 20px;
|
301
|
-
}
|
302
|
-
|
303
|
-
img {
|
304
|
-
object-fit: cover;
|
305
|
-
}
|
306
|
-
|
307
|
-
.sb-section-title {
|
308
|
-
margin-bottom: 32px;
|
309
|
-
}
|
310
|
-
|
311
|
-
.sb-section a:not(h1 a, h2 a, h3 a) {
|
312
|
-
font-size: 14px;
|
313
|
-
}
|
314
|
-
|
315
|
-
.sb-section-item, .sb-grid-item {
|
316
|
-
flex: 1;
|
317
|
-
display: flex;
|
318
|
-
flex-direction: column;
|
319
|
-
}
|
320
|
-
|
321
|
-
.sb-section-item-heading {
|
322
|
-
padding-top: 20px !important;
|
323
|
-
padding-bottom: 5px !important;
|
324
|
-
margin: 0 !important;
|
325
|
-
}
|
326
|
-
.sb-section-item-paragraph {
|
327
|
-
margin: 0;
|
328
|
-
padding-bottom: 10px;
|
329
|
-
}
|
330
|
-
|
331
|
-
.sb-chevron {
|
332
|
-
margin-left: 5px;
|
333
|
-
}
|
334
|
-
|
335
|
-
.sb-features-grid {
|
336
|
-
display: grid;
|
337
|
-
grid-template-columns: repeat(2, 1fr);
|
338
|
-
grid-gap: 32px 20px;
|
339
|
-
}
|
340
|
-
|
341
|
-
.sb-socials {
|
342
|
-
display: grid;
|
343
|
-
grid-template-columns: repeat(4, 1fr);
|
344
|
-
}
|
345
|
-
|
346
|
-
.sb-socials p {
|
347
|
-
margin-bottom: 10px;
|
348
|
-
}
|
349
|
-
|
350
|
-
.sb-explore-image {
|
351
|
-
max-height: 32px;
|
352
|
-
align-self: flex-start;
|
353
|
-
}
|
354
|
-
|
355
|
-
.sb-addon {
|
356
|
-
width: 100%;
|
357
|
-
display: flex;
|
358
|
-
align-items: center;
|
359
|
-
position: relative;
|
360
|
-
background-color: #EEF3F8;
|
361
|
-
border-radius: 5px;
|
362
|
-
border: 1px solid rgba(0, 0, 0, 0.05);
|
363
|
-
background: #EEF3F8;
|
364
|
-
height: 180px;
|
365
|
-
margin-bottom: 48px;
|
366
|
-
overflow: hidden;
|
367
|
-
}
|
368
|
-
|
369
|
-
.sb-addon-text {
|
370
|
-
padding-left: 48px;
|
371
|
-
max-width: 240px;
|
372
|
-
}
|
373
|
-
|
374
|
-
.sb-addon-text h4 {
|
375
|
-
padding-top: 0px;
|
376
|
-
}
|
377
|
-
|
378
|
-
.sb-addon-img {
|
379
|
-
position: absolute;
|
380
|
-
left: 345px;
|
381
|
-
top: 0;
|
382
|
-
height: 100%;
|
383
|
-
width: 200%;
|
384
|
-
overflow: hidden;
|
385
|
-
}
|
386
|
-
|
387
|
-
.sb-addon-img img {
|
388
|
-
width: 650px;
|
389
|
-
transform: rotate(-15deg);
|
390
|
-
margin-left: 40px;
|
391
|
-
margin-top: -72px;
|
392
|
-
box-shadow: 0 0 1px rgba(255, 255, 255, 0);
|
393
|
-
backface-visibility: hidden;
|
394
|
-
}
|
395
|
-
|
396
|
-
@media screen and (max-width: 800px) {
|
397
|
-
.sb-addon-img {
|
398
|
-
left: 300px;
|
399
|
-
}
|
400
|
-
}
|
401
|
-
|
402
|
-
@media screen and (max-width: 600px) {
|
403
|
-
.sb-section {
|
404
|
-
flex-direction: column;
|
405
|
-
}
|
406
|
-
|
407
|
-
.sb-features-grid {
|
408
|
-
grid-template-columns: repeat(1, 1fr);
|
409
|
-
}
|
410
|
-
|
411
|
-
.sb-socials {
|
412
|
-
grid-template-columns: repeat(2, 1fr);
|
413
|
-
}
|
414
|
-
|
415
|
-
.sb-addon {
|
416
|
-
height: 280px;
|
417
|
-
align-items: flex-start;
|
418
|
-
padding-top: 32px;
|
419
|
-
overflow: hidden;
|
420
|
-
}
|
421
|
-
|
422
|
-
.sb-addon-text {
|
423
|
-
padding-left: 24px;
|
424
|
-
}
|
425
|
-
|
426
|
-
.sb-addon-img {
|
427
|
-
right: 0;
|
428
|
-
left: 0;
|
429
|
-
top: 130px;
|
430
|
-
bottom: 0;
|
431
|
-
overflow: hidden;
|
432
|
-
height: auto;
|
433
|
-
width: 124%;
|
434
|
-
}
|
435
|
-
|
436
|
-
.sb-addon-img img {
|
437
|
-
width: 1200px;
|
438
|
-
transform: rotate(-12deg);
|
439
|
-
margin-left: 0;
|
440
|
-
margin-top: 48px;
|
441
|
-
margin-bottom: -40px;
|
442
|
-
margin-left: -24px;
|
443
|
-
}
|
444
|
-
}
|
445
|
-
`}
|
446
|
-
</style>
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
2
|
-
import { fn } from '@storybook/test';
|
3
|
-
|
4
|
-
import { Header } from './Header';
|
5
|
-
|
6
|
-
const meta: Meta<typeof Header> = {
|
7
|
-
title: 'Example/Header',
|
8
|
-
component: Header,
|
9
|
-
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
10
|
-
tags: ['autodocs'],
|
11
|
-
parameters: {
|
12
|
-
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
13
|
-
layout: 'fullscreen',
|
14
|
-
},
|
15
|
-
args: {
|
16
|
-
onLogin: fn(),
|
17
|
-
onLogout: fn(),
|
18
|
-
onCreateAccount: fn(),
|
19
|
-
},
|
20
|
-
};
|
21
|
-
|
22
|
-
export default meta;
|
23
|
-
type Story = StoryObj<typeof Header>;
|
24
|
-
|
25
|
-
export const LoggedIn: Story = {
|
26
|
-
args: {
|
27
|
-
user: {
|
28
|
-
name: 'Jane Doe',
|
29
|
-
},
|
30
|
-
},
|
31
|
-
};
|
32
|
-
|
33
|
-
export const LoggedOut: Story = {};
|