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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

component reactive in docs while not reactive in canvas #14031

Closed
Sebastian1830 opened this issue Feb 23, 2021 · 3 comments
Closed

component reactive in docs while not reactive in canvas #14031

Sebastian1830 opened this issue Feb 23, 2021 · 3 comments

Comments

@Sebastian1830
Copy link

I have the same problem 馃槥

  • node v12.20.2
  • npm v6.14.11

mycomponent.vue

<template>
  <div>
    <div class='row'>
      <div class='col-12 bg-primary is-click'>
        <span class='text-h6 q-mx-sm'>{{ hi }}</span>
      </div>
      <div v-if='open' class='col-12 bg-grey-3'>
        <slot></slot>
      </div>
    </div>
  </div>
</template>

<script lang='ts'>
import { defineComponent, reactive, computed } from 'vue';

export default defineComponent({
  name: 'detailsHidden',
  props: {
    open: { type: Boolean, default: false },
    name: { type: String, default: 'Juan' }
  },
  setup(props) {
    const p = reactive(props)
    const hi = computed(() => { return `Welcome ${p.name} !` })
    return { hi }
  }
});
</script>

<style lang='scss' scoped>
  @import "detailsHidden.scss";
</style>

mycomponent.stories.js

import detailsHidden from './detailsHidden.vue';
import { QBtn } from 'quasar';

export default {
  title: 'Test/FuDetailsHidden',
  component: detailsHidden,
  argTypes: {
    name: { control: "text" },
    open: { control: "boolean" }
  }
}

const Template = (args, { argTypes }) => ({
    components: { detailsHidden, QBtn },
    props: Object.keys(argTypes),
    template: '<details-hidden v-bind="$props">' +
      '           <div class=\'q-mx-md q-my-md\'>\n' +
      '               <span>This is a storybook</span>\n' +
      '               <q-btn color="secondary" label="Secondary" class="q-ml-lg" />\n' +
      '           </div>' +
      '        </details-hidden>'
});

export const FirstStory = Template.bind({});
FirstStory.args = {
  name: 'Sophia',
  open: false
}

package.json

{
...
    "@storybook/addon-actions": "^6.2.0-alpha.29",
    "@storybook/addon-essentials": "^6.2.0-alpha.29",
    "@storybook/addon-links": "^6.2.0-alpha.29",
    "@storybook/addon-postcss": "^2.0.0",
    "@storybook/vue3": "^6.2.0-alpha.29",
...
}

What can be wrong? , please help me 馃檶

Originally posted by @Sebastian1830 in #11501 (comment)

@phated
Copy link
Contributor

phated commented Feb 24, 2021

@Sebastian1830 the way you write stories for Vue 3 has recently been changed. You now need to use:

const Template = (args) => ({
    components: { detailsHidden, QBtn },
    template: '<details-hidden v-bind="args">' +
      '           <div class=\'q-mx-md q-my-md\'>\n' +
      '               <span>This is a storybook</span>\n' +
      '               <q-btn color="secondary" label="Secondary" class="q-ml-lg" />\n' +
      '           </div>' +
      '        </details-hidden>',
    setup() {
        return { args };
    }
});

@Sebastian1830
Copy link
Author

Thank you very much, is there any place where I can access the information of the most recent changes? 馃槂

@shilman
Copy link
Member

shilman commented Feb 24, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants