import Button from './Button.vue'

// More on default export: https://storybook.js.org/docs/vue/writing-stories/introduction#default-export
export default {
  title: '组件示例/Button',
  component: Button,
  // More on argTypes: https://storybook.js.org/docs/vue/api/argtypes
  argTypes: {
    backgroundColor: {
      control: 'color', // props里的backgroundColor属性用color控件展示
      description: '手动添加的背景色描述', // 定义props的描述
    },

    size: {
      control: { type: 'select' }, // props里的size属性用下拉单选控件展示
      options: ['small', 'medium', 'large'], // select下拉框选项
    },
    // onClick: { action: 'clicked' }
  },
}


// More on component templates: https://storybook.js.org/docs/vue/writing-stories/introduction#using-args
/**
 * 将Primary,Secondary,Large,Small这几个示例中可复用的部分抽离成Template
 * 这样以后，定义Primary等示例时无需再重复写props,components,template这几个属性了
 */
const Template = (args, { argTypes }) => ({
  props: Object.keys(argTypes), // 定义组件的props
  components: { Button },
  template: '<Button @onClick="onClick" v-bind="$props" />',
})

export const Primary = Template.bind({}) // 使用之前定义好的Template模板
// More on args: https://storybook.js.org/docs/vue/writing-stories/args
// 为Primary这个示例定制传入的props
Primary.args = {
  primary: true,
}
Primary.storyName = '中文标题';

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

export const Small = Template.bind({})
Small.args = {
  size: 'small',
}
