1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
| import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; import { Input } from '@hardyhu-ui/core';
const meta: Meta<typeof Input> = { title: 'Components/Input', component: Input, argTypes: { variant: { control: { type: 'select' }, options: ['outlined', 'filled', 'standard'], description: 'Input variant style', table: { type: { summary: 'string' }, defaultValue: { summary: 'outlined' }, }, }, size: { control: { type: 'select' }, options: ['small', 'medium', 'large'], description: 'Input size', table: { type: { summary: 'string' }, defaultValue: { summary: 'medium' }, }, }, label: { control: 'text', description: 'Input label', }, placeholder: { control: 'text', description: 'Input placeholder', }, disabled: { control: 'boolean', description: 'Disables the input', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, }, }, error: { control: 'text', description: 'Error message', }, helperText: { control: 'text', description: 'Helper text', }, fullWidth: { control: 'boolean', description: 'Makes input full width', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, }, }, onChange: { action: 'changed' }, }, parameters: { docs: { description: { component: 'A customizable input component with different variants and sizes.', }, }, }, };
export default meta; type Story = StoryObj<typeof Input>;
export const Default: Story = { args: { label: 'Default Input', placeholder: 'Enter text...', }, };
export const Outlined: Story = { args: { label: 'Outlined Input', placeholder: 'Enter text...', variant: 'outlined', }, };
export const Filled: Story = { args: { label: 'Filled Input', placeholder: 'Enter text...', variant: 'filled', }, };
export const Standard: Story = { args: { label: 'Standard Input', placeholder: 'Enter text...', variant: 'standard', }, };
export const Sizes: Story = { render: () => ( <div style={{ display: 'flex', gap: '1rem', flexDirection: 'column' }}> <Input size="small" label="Small Input" placeholder="Small..." /> <Input size="medium" label="Medium Input" placeholder="Medium..." /> <Input size="large" label="Large Input" placeholder="Large..." /> </div> ), };
export const WithError: Story = { args: { label: 'Email', placeholder: 'Enter your email', error: 'Please enter a valid email address', }, };
export const WithHelperText: Story = { args: { label: 'Password', type: 'password', placeholder: 'Enter your password', helperText: 'Password must be at least 8 characters', }, };
export const Disabled: Story = { args: { label: 'Disabled Input', placeholder: 'You cannot edit this field', disabled: true, }, };
export const FullWidth: Story = { args: { label: 'Full Width Input', placeholder: 'This input takes up the full width', fullWidth: true, }, };
export const WithIcons: Story = { render: () => ( <div style={{ display: 'flex', gap: '1rem', flexDirection: 'column' }}> <Input label="Search" placeholder="Search..." startIcon={<span style={{ fontSize: '1.2em' }}>🔍</span>} /> <Input label="Password" type="password" placeholder="Enter password" endIcon={<span style={{ fontSize: '1.2em' }}>👁️</span>} /> <Input label="Location" placeholder="Enter your location" startIcon={<span style={{ fontSize: '1.2em' }}>📍</span>} endIcon={<span style={{ fontSize: '1.2em' }}>📌</span>} /> </div> ), };
|