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

Vue: map args correctly in CSF3 implicit render function #18209

Merged
merged 3 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/vue/src/client/preview/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { renderToDOM } from './render';
export { render, renderToDOM } from './render';
export { decorateStory } from './decorateStory';

export const parameters = { framework: 'vue' };
4 changes: 2 additions & 2 deletions app/vue/src/client/preview/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const root = new Vue({
});

export const render: ArgsStoryFn<VueFramework> = (props, context) => {
const { id, component: Component } = context;
const { id, component: Component, argTypes } = context;
const component = Component as VueFramework['component'] & {
__docgenInfo?: { displayName: string };
props: Record<string, any>;
Expand All @@ -49,7 +49,7 @@ export const render: ArgsStoryFn<VueFramework> = (props, context) => {
}

return {
props: component.props,
props: Object.keys(argTypes),
components: { [componentName]: component },
template: `<${componentName} v-bind="$props" />`,
};
Expand Down
7 changes: 7 additions & 0 deletions examples/vue-cli/src/button/Button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ export const ButtonWithProps: Story = (args, { argTypes }) => ({
ButtonWithProps.args = {
size: 'big',
};

export const WithDefaultRender = {
args: {
size: 'small',
label: 'Button with default render',
},
};
9 changes: 8 additions & 1 deletion examples/vue-cli/src/button/Button.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<div class="button" :class="`size-${size}`">
<!-- @slot Button content, e.g. label text -->
<slot></slot>
<slot>
{{label}}
</slot>
</div>
</template>

Expand All @@ -21,6 +23,11 @@ export default class Button extends Vue {
* @values default,small,big
*/
@Prop({ type: String, default: 'default' }) readonly size!: ButtonSize;

/**
* Label of the button
*/
@Prop({ type: String, default: '' }) readonly label!: string;
}
</script>

Expand Down