- Batch 6: FAB, FormField, FloatingInput, AvatarUpload - Batch 7: Modal, ConfirmationDialog, ImageViewerModal, ErrorDisplay, LoadingState - Batch 8: DataList, WaveformVisualizer, OptimizedImage, VirtualizedList - Batch 9: ImageCropper, LoadingSpinner, FocusTrap - Achieved total coverage for src/components/ui
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
import type { Meta, StoryObj } from '@storybook/react';
|
|
import { FormField, Input, Textarea, Select } from './FormField';
|
|
|
|
const meta = {
|
|
title: 'UI/FormField',
|
|
component: FormField,
|
|
tags: ['autodocs'],
|
|
argTypes: {
|
|
label: { control: 'text' },
|
|
error: { control: 'text' },
|
|
helpText: { control: 'text' },
|
|
required: { control: 'boolean' },
|
|
},
|
|
} satisfies Meta<typeof FormField>;
|
|
|
|
export default meta;
|
|
type Story = StoryObj<typeof meta>;
|
|
|
|
export const Default: Story = {
|
|
args: {
|
|
label: 'Username',
|
|
children: <Input placeholder="Enter username" />,
|
|
},
|
|
};
|
|
|
|
export const WithError: Story = {
|
|
args: {
|
|
label: 'Email',
|
|
required: true,
|
|
error: 'Invalid email address',
|
|
children: <Input error placeholder="Enter email" defaultValue="invalid@" />,
|
|
},
|
|
};
|
|
|
|
export const WithHelpText: Story = {
|
|
args: {
|
|
label: 'Bio',
|
|
helpText: 'Tell us a little bit about yourself (max 140 chars)',
|
|
children: <Textarea placeholder="Type your bio here..." />,
|
|
},
|
|
};
|
|
|
|
export const WithSelect: Story = {
|
|
args: {
|
|
label: 'Role',
|
|
required: true,
|
|
children: (
|
|
<Select
|
|
options={[
|
|
{ value: 'user', label: 'User' },
|
|
{ value: 'admin', label: 'Admin' },
|
|
]}
|
|
/>
|
|
),
|
|
},
|
|
};
|