Merge branch 'next' of github.com:storybookjs/storybook into 20600-bug-storybook-docs-css-cascading-into-our-components

This commit is contained in:
Jeppe Reinhold 2023-02-18 23:13:14 +01:00
commit 1ad7210a93
3 changed files with 12 additions and 7 deletions

View File

@ -80,15 +80,16 @@ export const render: ArgsStoryFn<VueRenderer> = (args, context) => {
.filter((argType) => argType?.table?.category === 'events')
.map((argType) => argType.name);
const camelCase = (str: string) => str.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
if (eventProps.length) {
eventsBinding = eventProps.map((name) => `@${name}="$props.${name}"`).join(' ');
eventsBinding = `${eventsBinding} `;
eventsBinding = eventProps.map((name) => `@${name}="$props['${camelCase(name)}']"`).join(' ');
}
return {
props: Object.keys(argTypes),
components: { [componentName]: component },
template: `<${componentName} ${eventsBinding}v-bind="filterOutEventProps($props)" />`,
template: `<${componentName} ${eventsBinding} v-bind="filterOutEventProps($props)" />`,
methods: {
filterOutEventProps(props: object) {
return Object.fromEntries(

View File

@ -19,8 +19,10 @@ export default meta;
type Story = StoryObj<typeof meta>;
export const Primary: Story = {
backgroundColor: '#ff0',
label: 'Button',
args: {
backgroundColor: '#ff0',
label: 'Button',
},
};
export const Secondary: Story = {

View File

@ -18,8 +18,10 @@ export default meta;
type Story = StoryObj<typeof Button>;
export const Primary: Story = {
backgroundColor: '#ff0',
label: 'Button',
args: {
backgroundColor: '#ff0',
label: 'Button',
},
};
export const Secondary: Story = {