2021-06-02 03:54:00 +00:00
const webpackOverride = require ( '../webpack.config' ) ;
2024-09-26 07:10:37 +00:00
const staticDirs = [
{
2024-10-11 03:31:11 +00:00
from : '../../../plugins/woocommerce/client/admin/client' ,
to : 'main/plugins/woocommerce/client/admin/client' ,
2024-09-26 07:10:37 +00:00
} ,
] ;
if ( process . env . NODE _ENV && process . env . NODE _ENV === 'production' ) {
// Add WooCommerce Blocks Storybook for build process.
staticDirs . push ( {
from : '../../../plugins/woocommerce-blocks/storybook/dist' ,
to : '/assets/woocommerce-blocks' ,
} ) ;
}
2021-06-02 03:54:00 +00:00
module . exports = {
stories : [
// WooCommerce Admin / @woocommerce/components components
2024-09-09 15:06:01 +00:00
'../../../packages/js/components/src/**/stories/*.story.@(js|tsx)' ,
2021-06-02 03:54:00 +00:00
// WooCommerce Admin / @woocommerce/experimental components
2024-09-09 15:06:01 +00:00
'../../../packages/js/experimental/src/**/stories/*.story.@(js|tsx)' ,
2023-08-22 09:58:33 +00:00
// WooCommerce Admin / @woocommerce/onboarding components
2024-09-09 15:06:01 +00:00
'../../../packages/js/onboarding/src/**/stories/*.story.@(js|tsx)' ,
'../../../packages/js/product-editor/src/**/*.(stories|story).@(js|tsx)' ,
2024-10-11 03:31:11 +00:00
'../../../plugins/woocommerce/client/admin/client/**/stories/*.story.@(js|tsx)' ,
2021-06-02 03:54:00 +00:00
] ,
2024-09-26 07:10:37 +00:00
refs : ( config , { configType } ) => {
if ( configType === 'DEVELOPMENT' ) {
2024-10-21 20:14:55 +00:00
// WooCommerce Blocks gets automatically on port 6006 run when you run pnpm --filter=@woocommerce/storybook watch:build
return {
'woocommerce-blocks' : {
expanded : false ,
title : 'WooCommerce Blocks' ,
url : 'http://localhost:6006' ,
} ,
} ;
2024-09-26 07:10:37 +00:00
}
2024-09-26 12:24:29 +00:00
let pathPrefix = (
process . env . STORYBOOK _COMPOSITION _PATH _PREFIX ? ? ''
) . trim ( ) ;
if ( pathPrefix && ! pathPrefix . startsWith ( '/' ) ) {
pathPrefix = '/' + pathPrefix ;
}
2024-09-26 07:10:37 +00:00
return {
'woocommerce-blocks' : {
expanded : false ,
title : 'WooCommerce Blocks' ,
2024-09-26 12:24:29 +00:00
url : pathPrefix + '/assets/woocommerce-blocks' ,
2024-09-26 07:10:37 +00:00
} ,
} ;
} ,
2021-06-02 03:54:00 +00:00
addons : [
'@storybook/addon-docs' ,
2022-03-18 11:45:14 +00:00
'@storybook/addon-controls' ,
// This package has been deprecated, in favor of @storybook/addon-controls
// However, it is still needed for the <Timeline /> story because changing the values with @storybook/addon-controls makes it crash. It seems that we cannot have jsx elements in props.
2021-06-02 03:54:00 +00:00
'@storybook/addon-viewport' ,
'@storybook/addon-a11y' ,
'@storybook/addon-actions' ,
'@storybook/addon-links' ,
] ,
typescript : {
reactDocgen : 'react-docgen-typescript' ,
} ,
2024-09-26 07:10:37 +00:00
staticDirs ,
2023-07-24 12:34:38 +00:00
2021-06-02 03:54:00 +00:00
webpackFinal : webpackOverride ,
2021-12-21 02:48:28 +00:00
previewHead : ( head ) => `
$ { head }
$ {
process . env . USE _RTL _STYLE === 'true'
? `
< link href = "experimental-css/style-rtl.css" rel = "stylesheet" / >
< link href = "component-css/style-rtl.css" rel = "stylesheet" / >
2023-08-22 09:58:33 +00:00
< link href = "onboarding-css/style-rtl.css" rel = "stylesheet" / >
2023-12-19 16:09:30 +00:00
< link href = "product-editor-css/style-rtl.css" rel = "stylesheet" / >
2023-07-24 12:34:38 +00:00
< link href = "app-css/style-rtl.css" rel = "stylesheet" / >
2021-12-21 02:48:28 +00:00
`
: `
< link href = "component-css/style.css" rel = "stylesheet" / >
< link href = "experimental-css/style.css" rel = "stylesheet" / >
2023-08-22 09:58:33 +00:00
< link href = "onboarding-css/style.css" rel = "stylesheet" / >
2023-12-19 16:09:30 +00:00
< link href = "product-editor-css/style.css" rel = "stylesheet" / >
2023-07-24 12:34:38 +00:00
< link href = "app-css/style.css" rel = "stylesheet" / >
2021-12-21 02:48:28 +00:00
`
}
< style >
/* Use system font, consistent with WordPress core (wp-admin) */
body {
font - family : - apple - system , BlinkMacSystemFont , 'Segoe UI' , Roboto ,
Oxygen - Sans , Ubuntu , Cantarell , 'Helvetica Neue' , sans - serif ;
}
< / s t y l e >
` ,
2024-09-09 15:06:01 +00:00
2023-07-24 12:34:38 +00:00
previewBody : ( body ) => `
< div id = "wpwrap" >
2023-09-15 20:06:42 +00:00
< div class = "woocommerce-layout woocommerce-admin-page" >
2023-07-24 12:34:38 +00:00
$ { body }
` ,
2024-09-09 15:06:01 +00:00
framework : {
name : '@storybook/react-webpack5' ,
options : { } ,
} ,
docs : {
autodocs : true ,
} ,
2021-06-02 03:54:00 +00:00
} ;