import { faAlignCenter, faAlignJustify, faAlignLeft, faAlignRight, faArrowLeft, faArrowRight, faBold, faCodeBranch, faHeart, faPause, faShoppingCart, faSignOut, faStrikethrough, faUnderline, } from '@fortawesome/free-solid-svg-icons' import { action } from '@storybook/addon-actions' import type { Meta, StoryObj } from '@storybook/vue3' import Button from 'src/components/button/Button.vue' import ButtonGroup from 'src/components/button/ButtonGroup.vue' import Icon from 'src/components/icon/Icon.vue' const meta = { component: Button, parameters: { actions: { argTypesRegex: `^(${(Button.emits as string[])?.join('|')})$`, }, }, argTypes: { default: { description: 'The default slot', control: { type: 'text' }, table: { type: { summary: 'node' } }, }, animated: { description: 'The slot of what is displayed when the cursor hovers', control: 'text', table: { type: { summary: 'node' } }, }, leftLabel: { description: 'The slot of what is displayed when the cursor hovers', control: { type: 'text' }, table: { type: { summary: 'node' } }, }, rightLabel: { description: 'The slot of what is displayed when the cursor hovers', control: { type: 'text' }, table: { type: { summary: 'node' } }, }, animation: { description: 'animation', control: 'inline-radio', options: ['horizontal', 'vertical', 'fade'], table: { category: 'props', type: { summary: 'enum' }, defaultValue: { summary: 'horizontal' }, }, }, content: { control: 'text', description: 'If you only have plain text, you can using this prop', table: { category: 'props', type: { summary: 'text' }, }, }, size: { description: 'The size of button
Also you can use `mini` `small` `large` `massive` prop directly', control: { type: 'inline-radio' }, options: ['mini', 'small', 'middle', 'large', 'massive'], table: { category: 'props', type: { summary: 'enum' }, defaultValue: { summary: 'middle' }, }, }, active: { control: 'boolean', table: { category: 'props', defaultValue: { summary: 'false' }, }, }, loading: { control: 'boolean', table: { category: 'props', defaultValue: { summary: 'false' }, }, }, click: { action: 'clicked' }, }, args: { default: 'Button', click: null, }, render: (args: Record, { argTypes }) => { const attrs: Record = {} const props: Record = {} const slots: Record = {} const events: Record = {} for (const [k, argType] of Object.entries(argTypes) as any) { const v = args[k] if (k in Button.props) props[k] = v else if (argType.table?.category === 'slots') slots[k] = argType else if (argType.table?.category === 'events' && v) events[k] = v else if (v) attrs[k] = v } const { default: defaultSlot, ...otherSlots } = slots return { components: { Button }, props: Object.keys(argTypes), setup () { return { action, args } }, template: ``, } }, } satisfies Meta export default meta type Story = StoryObj export const Basic: Story = { args: { default: 'Button', }, } /** * Buttons can have the following states: `normal` `active` `disabled` and `loading` */ export const Status: Story = { render: (args) => { return { components: { Button }, template: `


`, } }, } export const IconStory: Story = { name: 'Icon', render: (args) => { return { components: { Button }, setup () { return { faShoppingCart, faSignOut } }, template: `


`, } }, } export const Colored: Story = { render: args => ({ components: { Button }, setup: () => ({ faPause }), template: `




`, }), } export const Ghost: Story = { render: args => ({ components: { Button }, setup: () => ({ faPause }), template: `



`, }), } export const Animated: Story = { render: args => ({ components: { Button, Icon }, setup: () => ({ faArrowRight, faShoppingCart }), template: ` `, }), } export const Fluid: Story = { render: () => ({ components: { Button }, setup: () => ({ faPause }), template: ` `, }), } export const Size: Story = { render: () => ({ components: { Button }, setup: () => ({ faPause, faHeart, faCodeBranch, faShoppingCart }), template: `




`, }), } export const ButtonGroupStory: Story = { name: 'ButtonGroup', render: () => ({ components: { Button, ButtonGroup }, setup: () => ({ faAlignCenter, faAlignJustify, faAlignLeft, faAlignRight, faArrowRight, faArrowLeft, faBold, faUnderline, faStrikethrough, }), template: `
`, }), }