Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to add support for CSF3 render preset #76

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/example-react/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ module.exports = {
core: {
builder: 'storybook-builder-vite',
},
features: {
storyStoreV7: true,
},
async viteFinal(config, { configType }) {
// customize the Vite config here
return config;
Expand Down
43 changes: 22 additions & 21 deletions packages/example-react/stories/Button.stories.jsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
import { Button } from './Button';

export default {
title: 'Example/Button',
component: Button,
argTypes: {
backgroundColor: { control: 'color' },
},
};

const Template = (args) => <Button {...args} />;
export const Primary = {
args: {
primary: true,
label: 'Button',
}
}

export const Primary = Template.bind({});
Primary.args = {
primary: true,
label: 'Button',
};

export const Secondary = Template.bind({});
Secondary.args = {
label: 'Button',
};
export const Secondary = {
args: {
label: 'Button',
}
}

export const Large = Template.bind({});
Large.args = {
size: 'large',
label: 'Button',
};
export const Large = {
args: {
size: 'large',
label: 'Button',
}
}

export const Small = Template.bind({});
Small.args = {
size: 'small',
label: 'Button',
export const Small = {
args: {
size: 'small',
label: 'Button',
}
};
5 changes: 4 additions & 1 deletion packages/storybook-builder-vite/codegen-iframe-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like setGlobalRender is not exported by https://github.com/storybookjs/storybook/blob/c1befe4b2400920a6c52fdc947d8e598cc7e35e1/lib/client-api/src/index.ts#L1-L7.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import { logger } from '@storybook/client-logger';
${absoluteFilesToImport(configEntries, 'config')}
${absoluteFilesToImport(storyEntries, 'story')}
Expand Down Expand Up @@ -98,6 +98,9 @@ module.exports.generateIframeScriptCode =
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
return console.log(key + ' was not supported :( !');
Expand Down