import type { Meta, StoryObj } from '@storybook/react-vite' import { expect, fn, userEvent, within } from 'storybook/test' import { ButtonWidget } from './ButtonWidget' import { ButtonArrayLayout } from './ButtonArrayLayout' const meta = { title: 'Components/Button', component: ButtonWidget, tags: ['autodocs'], parameters: { layout: 'centered' }, argTypes: { style: { control: 'select', options: ['SOLID', 'OUTLINE', 'GHOST', 'LINK'] }, color: { control: 'text' }, size: { control: 'select', options: ['SMALL', 'STANDARD', 'MEDIUM', 'LARGE'] }, }, } satisfies Meta export default meta type Story = StoryObj export const Default: Story = { args: { label: 'Submit', style: 'SOLID', color: 'ACCENT', size: 'STANDARD', saveInto: fn(), }, play: async ({ canvasElement, args }) => { const canvas = within(canvasElement) const button = canvas.getByRole('button', { name: 'Submit' }) await expect(button).toBeVisible() await userEvent.click(button) await expect(args.saveInto).toHaveBeenCalledOnce() }, } export const SemanticColorsSolid: Story = { render: () => ( ), } export const SemanticColorsOutline: Story = { render: () => ( ), } export const ButtonStyles: Story = { render: () => ( ), } export const ButtonSizes: Story = { render: () => ( ), } export const HexColorsSolid: Story = { render: () => ( ), } export const HexColorsOutline: Story = { render: () => ( ), } export const WithActions: Story = { render: () => ( alert('Add Another clicked') }, { label: 'Delete', style: 'SOLID', color: 'NEGATIVE', saveInto: () => alert('Delete clicked') }, ]} /> ), } export const LinkStyle: Story = { args: { label: 'Cancel', style: 'LINK', color: 'ACCENT', }, } export const MixedButtonTypes: Story = { name: 'Icon Buttons', render: () => ( ), }