From bffd6c04f6872f37482c032a631458f3bf9011b2 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Fri, 23 Jul 2021 17:43:08 +0800 Subject: [PATCH 1/6] Attempt to add support for CSF3 global render function --- packages/example-react/.storybook/main.js | 3 +++ packages/example-react/stories/Button.stories.jsx | 9 +++++---- packages/storybook-builder-vite/codegen-iframe-script.js | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/example-react/.storybook/main.js b/packages/example-react/.storybook/main.js index 5ea2c057..53a20532 100644 --- a/packages/example-react/.storybook/main.js +++ b/packages/example-react/.storybook/main.js @@ -19,4 +19,7 @@ module.exports = { // customize the Vite config here return config; }, + features: { + previewCsfV3: true, + }, }; diff --git a/packages/example-react/stories/Button.stories.jsx b/packages/example-react/stories/Button.stories.jsx index 3c3f7433..d17bdcb7 100644 --- a/packages/example-react/stories/Button.stories.jsx +++ b/packages/example-react/stories/Button.stories.jsx @@ -27,8 +27,9 @@ Large.args = { label: 'Button', }; -export const Small = Template.bind({}); -Small.args = { - size: 'small', - label: 'Button', +export const Small = { + args: { + size: 'small', + label: 'Button', + } }; diff --git a/packages/storybook-builder-vite/codegen-iframe-script.js b/packages/storybook-builder-vite/codegen-iframe-script.js index c25f9c64..082811a7 100644 --- a/packages/storybook-builder-vite/codegen-iframe-script.js +++ b/packages/storybook-builder-vite/codegen-iframe-script.js @@ -59,7 +59,7 @@ module.exports.generateIframeScriptCode = .map((entry) => `// preview entry\nimport '${entry}';`) .join('\n')} */ - import { addDecorator, addParameters, addLoader, addArgTypesEnhancer, addArgsEnhancer } from '@storybook/client-api'; + import { addDecorator, addParameters, addLoader, addArgTypesEnhancer, addArgsEnhancer, setGlobalRender } from '@storybook/client-api'; import { logger } from '@storybook/client-logger'; ${absoluteFilesToImport(configEntries, 'config')} ${absoluteFilesToImport(storyEntries, 'story')} @@ -97,6 +97,8 @@ module.exports.generateIframeScriptCode = case 'decorateStory': case 'renderToDOM': { return null; // This key is not handled directly in v6 mode. + case 'render': { + return setGlobalRender(value); } default: { // eslint-disable-next-line prefer-template From cc2a6e2667594c4952c24903e9000983a7752940 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Wed, 29 Dec 2021 13:17:49 -0500 Subject: [PATCH 2/6] Remove unnecessary feature flag --- packages/example-react/.storybook/main.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/example-react/.storybook/main.js b/packages/example-react/.storybook/main.js index 53a20532..5ea2c057 100644 --- a/packages/example-react/.storybook/main.js +++ b/packages/example-react/.storybook/main.js @@ -19,7 +19,4 @@ module.exports = { // customize the Vite config here return config; }, - features: { - previewCsfV3: true, - }, }; From e778230fd225dd8b3bc04a1362de6c653a6ae8e3 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Tue, 4 Jan 2022 22:34:22 -0500 Subject: [PATCH 3/6] Add missing } --- packages/storybook-builder-vite/codegen-iframe-script.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/storybook-builder-vite/codegen-iframe-script.js b/packages/storybook-builder-vite/codegen-iframe-script.js index 082811a7..9a81813f 100644 --- a/packages/storybook-builder-vite/codegen-iframe-script.js +++ b/packages/storybook-builder-vite/codegen-iframe-script.js @@ -97,6 +97,7 @@ module.exports.generateIframeScriptCode = case 'decorateStory': case 'renderToDOM': { return null; // This key is not handled directly in v6 mode. + } case 'render': { return setGlobalRender(value); } From 1648db0fe8253afa2fded24f7e418883a6ea8890 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Tue, 4 Jan 2022 22:38:43 -0500 Subject: [PATCH 4/6] Convert react Button example stories to only CSF3 --- .../example-react/stories/Button.stories.jsx | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/example-react/stories/Button.stories.jsx b/packages/example-react/stories/Button.stories.jsx index d17bdcb7..d8a41560 100644 --- a/packages/example-react/stories/Button.stories.jsx +++ b/packages/example-react/stories/Button.stories.jsx @@ -8,24 +8,25 @@ export default { }, }; -const Template = (args) =>