storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
83.95k stars 9.21k forks source link

Show code not parsing correctly Vue 3 #14202

Closed RobineSavert closed 3 years ago

RobineSavert commented 3 years ago

Bug or support request summary

I recently updated my component library to Vue 3. Everything is working as intended, except for the Show Code tab. It shows everything in the callback, not just the template.

I used the Button story from the official Storybook documentation for Vue 3 and was able to reproduce this problem as well.

Steps to reproduce

You now see the entire callback instead of just the template:

zzBl0

Please specify which version of Storybook and optionally any affected addons that you're running

"dependencies": { "@storybook/theming": "^6.1.18", "core-js": "^3.6.5", "vue": "^3.0.0-beta.1" }, "devDependencies": { "@babel/core": "^7.12.10", "@storybook/addon-actions": "^6.2.0-beta.10", "@storybook/addon-essentials": "^6.2.0-beta.10", "@storybook/addon-links": "^6.2.0-beta.10", "@storybook/addons": "^6.1.18", "@storybook/vue": "^6.1.11", "@storybook/vue3": "^6.2.0-beta.10", "@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-plugin-unit-jest": "~4.5.0", "@vue/cli-service": "~4.5.0", "@vue/compiler-sfc": "^3.0.0-beta.1", "@vue/eslint-config-prettier": "^6.0.0", "@vue/test-utils": "^2.0.0-alpha.1", "babel-eslint": "^10.1.0", "babel-loader": "^8.2.2", "eslint": "^6.7.2", "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-vue": "^7.0.0-beta.4", "prettier": "^1.19.1", "vue-cli-plugin-vue-next": "~0.1.4", "vue-loader": "^16.1.2" }, "license": "MIT", "repository": { "type": "git", "url": "" }

Screenshots / Screencast / Code Snippets (Optional)

// import Button from './Button.vue';

export default {
  title: 'Components/Button',
  component: Button,
  argTypes: {
    backgroundColor: { control: 'color' },
    size: { control: { type: 'select', options: ['small', 'medium', 'large'] } },
  }
};

const Template = (args) => ({
  components: { Button },
  setup() {
    return { args };
  },
  template: '<my-button v-bind="args" />'
});

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

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

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

export const Small = Template.bind({});
Small.args = {
  size: 'small',
  label: 'Button',
  backgroundColor: ''
};
shilman commented 3 years ago

closing as dupe to #13917