Major categories fixed: - TS6133 (188): Remove unused imports (React, icons, types) and variables - TS2322 (222): Fix type mismatches in stories (satisfies Meta -> const meta: Meta), add nullish coalescing for optional values, fix component prop types - TS2345 (43): Fix argument type mismatches with proper null checks and type narrowing - TS2741 (21): Add missing required properties to mock/story data - TS2339 (19): Fix property access on incorrect types, add type guards - TS2353 (13): Remove extra properties from object literals or extend interfaces - TS2352 (11): Fix type conversion chains - TS2307 (9): Fix import paths and module references - Other (42): Fix implicit any, possibly undefined, export declarations Vite build and tsc --noEmit both pass cleanly. Co-authored-by: Cursor <cursoragent@cursor.com>
99 lines
3 KiB
TypeScript
99 lines
3 KiB
TypeScript
import type { Meta, StoryObj } from '@storybook/react';
|
|
import { Button } from './button';
|
|
import { Mail, Trash2 } from 'lucide-react';
|
|
|
|
const meta = {
|
|
title: 'Components/UI/Button',
|
|
component: Button,
|
|
tags: ['autodocs'],
|
|
argTypes: {
|
|
variant: {
|
|
control: 'select',
|
|
options: ['default', 'primary', 'destructive', 'outline', 'secondary', 'ghost', 'gaming', 'terminal', 'nature', 'glass'],
|
|
},
|
|
size: {
|
|
control: 'select',
|
|
options: ['default', 'sm', 'lg', 'icon'],
|
|
},
|
|
disabled: { control: 'boolean' },
|
|
asChild: { table: { disable: true } },
|
|
},
|
|
args: {
|
|
children: 'Button',
|
|
variant: 'default',
|
|
size: 'default',
|
|
}
|
|
} satisfies Meta<typeof Button>;
|
|
|
|
export default meta;
|
|
type Story = StoryObj<typeof meta>;
|
|
|
|
export const Default: Story = {};
|
|
|
|
export const Variants = {
|
|
render: () => (
|
|
<div className="flex flex-wrap gap-4 items-center bg-black/80 p-8 rounded-lg">
|
|
<Button variant="default">Default</Button>
|
|
<Button variant="secondary">Secondary</Button>
|
|
<Button variant="destructive">Destructive</Button>
|
|
<Button variant="outline">Outline</Button>
|
|
<Button variant="ghost">Ghost</Button>
|
|
<Button variant="primary">Primary</Button>
|
|
<Button variant="link">Link</Button>
|
|
<Button variant="default">Default Alt</Button>
|
|
<Button variant="glass">Glass</Button>
|
|
</div>
|
|
),
|
|
};
|
|
|
|
export const Sizes = {
|
|
render: () => (
|
|
<div className="flex flex-wrap gap-4 items-center">
|
|
<Button size="lg">Large</Button>
|
|
<Button size="default">Default</Button>
|
|
<Button size="sm">Small</Button>
|
|
<Button size="icon"><Mail className="w-4 h-4" /></Button>
|
|
</div>
|
|
),
|
|
};
|
|
|
|
export const WithIcon: Story = {
|
|
args: {
|
|
children: 'Email Login',
|
|
icon: <Mail className="w-4 h-4" />,
|
|
},
|
|
};
|
|
|
|
export const Destructive: Story = {
|
|
args: {
|
|
variant: 'destructive',
|
|
children: 'Delete Account',
|
|
icon: <Trash2 className="w-4 h-4" />,
|
|
},
|
|
};
|
|
|
|
export const LoadingState: Story = {
|
|
render: () => (
|
|
<Button disabled>
|
|
Loading...
|
|
</Button>
|
|
),
|
|
};
|
|
|
|
/** Very long label, very short label, and dark/light context. */
|
|
export const VisualStressTest: Story = {
|
|
render: () => (
|
|
<div className="flex flex-col gap-6 min-h-layout-story">
|
|
<div className="flex flex-wrap gap-4 items-center p-4 bg-background rounded-lg">
|
|
<Button>Short</Button>
|
|
<Button>This is a much longer button label to test wrapping and padding</Button>
|
|
<Button size="sm">Sm</Button>
|
|
<Button size="icon"><Mail className="w-4 h-4" /></Button>
|
|
</div>
|
|
<div className="flex flex-wrap gap-4 items-center p-4 bg-muted rounded-lg">
|
|
<Button variant="outline">Outline in muted</Button>
|
|
<Button variant="ghost">Ghost</Button>
|
|
</div>
|
|
</div>
|
|
),
|
|
};
|