Rebuild Tansy UI on Base UI with one API and dark mode (v0.3.0)
Every component is rebuilt on @base-ui/react with a single prop API, token-only colours and dark mode, and 28 new components are added. Components - New: Field, FeaturedTextArea, NumberInput, Combobox, CheckboxGroup, Slider, ToggleGroup/Toggle, IconButton, Dialog/Modal, AlertDialog, Drawer/Sheet, Popover, InfoTip, DropdownMenu, Tabs, Breadcrumb, Pagination, Toast (Toaster, useToast), Progress, Meter, Skeleton, CountBadge, Avatar/AvatarGroup, Kbd, Separator, Table - Rewritten: Button, Input, FeaturedInput, TextArea, Select, FeaturedSelect (real ARIA combobox), NativeSelect, Checkbox, Radio, Switch, Tooltip, Accordion, Alert, Spinner, Badge, Card - Removed TextField (use Input) and sonner (use Toast) Foundations - Semantic tokens (surfaces, text, borders, status ramps) in src/styles/tokens.css, with class-based dark mode - Visible focus rings, linked labels/descriptions/errors, alert roles by severity, keyboard support from Base UI - Fixed the Classic Blue ramp; Emerald, Amber and Teal 500 steps now carry white text at AA - Library build (per-component ES modules, types, tokens.css, exports) Quality - Vitest, Testing Library and axe tests for every component (289 tests) - scripts/check-stories.mjs renders every story in Chrome and fails on errors or axe violations, including contrast; all 423 stories pass in light and dark mode and in all seven palettes - Storybook: controls for every prop, open states for every popup, light/dark toolbar, Introduction guides, docs/CONVENTIONS.md BREAKING CHANGE: component props changed across the kit; see CHANGELOG.md.
This commit is contained in:
1 parent
dc5e6ff800
commit
f01de83733
185 files changed
+22542
-5182
No files matched your search
@@ -1,143 +1,136 @@
|
||||
import { useState } from 'react'
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite'
|
||||
import { AtSign, Search } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import { fn } from 'storybook/test'
|
||||
import { SIZES } from '../lib/styles'
|
||||
import { Input } from './Input'
|
||||
|
||||
const meta = {
|
||||
title: 'Forms/Input',
|
||||
component: Input,
|
||||
tags: ['autodocs'],
|
||||
// Fields read best at form width, not stretched across the canvas.
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<div className="max-w-sm">
|
||||
<Story />
|
||||
</div>
|
||||
),
|
||||
],
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component:
|
||||
'Plain input with a label above. For a floating label, a built-in password toggle, and a Lucide icon slot, see the **FeaturedInput** story group — both are exported from here.',
|
||||
'A single-line text input with its label above. `description` and `error` are linked to the input for screen readers. For a floating label, use `FeaturedInput`.',
|
||||
},
|
||||
},
|
||||
},
|
||||
argTypes: {
|
||||
size: { control: 'select', options: ['sm', 'md', 'lg'] },
|
||||
theme: { control: 'select', options: ['primary', 'secondary', 'success', 'error', 'warning', 'info'] },
|
||||
type: { control: 'select', options: ['text', 'email', 'password', 'number', 'tel', 'url', 'date'] },
|
||||
iconPosition: { control: 'radio', options: ['left', 'right'] },
|
||||
roundedFull: { control: 'boolean' },
|
||||
dashedBorder: { control: 'boolean' },
|
||||
label: { control: 'text' },
|
||||
description: { control: 'text' },
|
||||
error: { control: 'text' },
|
||||
placeholder: { control: 'text' },
|
||||
size: { control: 'inline-radio', options: SIZES, table: { defaultValue: { summary: 'md' } } },
|
||||
variant: {
|
||||
control: 'inline-radio',
|
||||
options: ['outline', 'filled', 'underline'],
|
||||
table: { defaultValue: { summary: 'outline' } },
|
||||
},
|
||||
type: { control: 'select', options: ['text', 'email', 'password', 'number', 'search', 'tel', 'url'] },
|
||||
required: { control: 'boolean' },
|
||||
disabled: { control: 'boolean' },
|
||||
label: { control: 'text' },
|
||||
placeholder: { control: 'text' },
|
||||
error: { control: 'text' },
|
||||
readOnly: { control: 'boolean' },
|
||||
startAddon: { control: 'text' },
|
||||
endAddon: { control: 'text' },
|
||||
startIcon: { control: false },
|
||||
endIcon: { control: false },
|
||||
},
|
||||
args: {
|
||||
label: 'Legal entity name',
|
||||
placeholder: 'Acme Corporation',
|
||||
type: 'text',
|
||||
label: 'Work email',
|
||||
placeholder: '[email protected]',
|
||||
type: 'email',
|
||||
size: 'md',
|
||||
theme: 'primary',
|
||||
iconPosition: 'left',
|
||||
roundedFull: false,
|
||||
dashedBorder: false,
|
||||
variant: 'outline',
|
||||
required: false,
|
||||
disabled: false,
|
||||
error: '',
|
||||
readOnly: false,
|
||||
onValueChange: fn(),
|
||||
},
|
||||
} satisfies Meta<typeof Input>
|
||||
|
||||
export default meta
|
||||
type Story = StoryObj<typeof meta>
|
||||
|
||||
function ControlledInput({
|
||||
initial = '',
|
||||
...args
|
||||
}: React.ComponentProps<typeof Input> & { initial?: string }) {
|
||||
const [value, setValue] = useState(initial)
|
||||
return <Input {...args} value={value} onChange={(e) => setValue(e.target.value)} />
|
||||
export const Playground: Story = {}
|
||||
|
||||
export const WithDescription: Story = {
|
||||
args: { description: 'Payslips are sent to this address.' },
|
||||
}
|
||||
|
||||
export const Playground: Story = {
|
||||
export const WithError: Story = {
|
||||
args: { defaultValue: 'jane.doe@', error: 'Enter a full email address, like [email protected].' },
|
||||
}
|
||||
|
||||
export const Required: Story = {
|
||||
args: { required: true },
|
||||
}
|
||||
|
||||
export const Disabled: Story = {
|
||||
args: { disabled: true, defaultValue: '[email protected]' },
|
||||
}
|
||||
|
||||
export const ReadOnly: Story = {
|
||||
args: { readOnly: true, defaultValue: '[email protected]', description: 'Managed by your identity provider.' },
|
||||
}
|
||||
|
||||
export const Variants: Story = {
|
||||
render: (args) => (
|
||||
<div className="max-w-md">
|
||||
<ControlledInput {...args} />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Types: Story = {
|
||||
render: () => (
|
||||
<div className="grid max-w-2xl gap-5 sm:grid-cols-2">
|
||||
<Input label="Full name" placeholder="Jane Doe" />
|
||||
<Input label="Email" type="email" placeholder="[email protected]" />
|
||||
<Input label="Phone" type="tel" placeholder="+91 98450 00000" />
|
||||
<Input label="Annual CTC" type="number" placeholder="1200000" />
|
||||
<Input label="Website" type="url" placeholder="https://example.com" />
|
||||
<Input label="Joining date" type="date" />
|
||||
<div className="grid gap-5">
|
||||
<Input {...args} variant="outline" label="Outline" />
|
||||
<Input {...args} variant="filled" label="Filled" />
|
||||
<Input {...args} variant="underline" label="Underline" />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Sizes: Story = {
|
||||
render: () => (
|
||||
<div className="flex max-w-md flex-col gap-5">
|
||||
{(['sm', 'md', 'lg'] as const).map((size) => (
|
||||
<ControlledInput key={size} size={size} label={`Size ${size}`} placeholder="Enter a value" />
|
||||
))}
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Themes: Story = {
|
||||
render: () => (
|
||||
<div className="grid max-w-2xl gap-5 sm:grid-cols-2">
|
||||
{(['primary', 'secondary', 'success', 'warning', 'info'] as const).map((theme) => (
|
||||
<ControlledInput key={theme} theme={theme} label={theme} placeholder="Focus me" />
|
||||
))}
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const WithError: Story = {
|
||||
render: () => (
|
||||
<div className="max-w-md">
|
||||
<Input
|
||||
label="PAN number"
|
||||
placeholder="ABCDE1234F"
|
||||
error="Enter a valid PAN number."
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Required: Story = {
|
||||
render: () => (
|
||||
<div className="max-w-md">
|
||||
<Input label="Entity name" required placeholder="Required field" />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Disabled: Story = {
|
||||
render: () => (
|
||||
<div className="max-w-md">
|
||||
<Input label="Entity ID" value="ENT-000142" disabled onChange={() => {}} />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const BorderStyles: Story = {
|
||||
render: () => (
|
||||
<div className="grid max-w-xl gap-5 sm:grid-cols-3">
|
||||
<Input label="Default" placeholder="Solid" />
|
||||
<Input label="Dashed" placeholder="Dashed" dashedBorder />
|
||||
<Input label="Pill" placeholder="Rounded" roundedFull />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
/** Requires the Remix Icon font; the `FeaturedInput` group below uses Lucide instead. */
|
||||
export const WithIconClass: Story = {
|
||||
args: { icon: 'ri-mail-line', placeholder: 'Email' },
|
||||
render: (args) => (
|
||||
<div className="max-w-md">
|
||||
<Input {...args} label="Email" />
|
||||
<div className="grid gap-5">
|
||||
{SIZES.map((size) => (
|
||||
<Input key={size} {...args} size={size} label={`Size ${size}`} />
|
||||
))}
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const WithIcons: Story = {
|
||||
render: (args) => (
|
||||
<div className="grid gap-5">
|
||||
<Input {...args} label="Search" type="search" placeholder="Search employees" startIcon={<Search />} />
|
||||
<Input {...args} label="Username" type="text" placeholder="jane" endIcon={<AtSign />} />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const WithAddons: Story = {
|
||||
render: (args) => (
|
||||
<div className="grid gap-5">
|
||||
<Input {...args} label="Website" type="text" placeholder="example" startAddon="https://" endAddon=".com" />
|
||||
<Input {...args} label="Amount" type="number" placeholder="0.00" startAddon="$" endAddon="USD" />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
function ControlledInput(args: Story['args']) {
|
||||
const [value, setValue] = useState('Jane Doe')
|
||||
return (
|
||||
<div className="grid gap-2">
|
||||
<Input {...args} label="Full name" type="text" value={value} onValueChange={setValue} />
|
||||
<p className="text-sm text-fg-muted">Value: {value || '(empty)'}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export const Controlled: Story = {
|
||||
render: (args) => <ControlledInput {...args} />,
|
||||
}
|
||||
Reference in new issue
Block a user