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
@@ -0,0 +1,204 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite'
|
||||
import { Bell, CalendarDays, Link2, SlidersHorizontal } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import { fn } from 'storybook/test'
|
||||
import { Button, IconButton } from './Button'
|
||||
import { Input } from './Input'
|
||||
import { Popover } from './Popover'
|
||||
import { POPUP_ALIGNS, POPUP_SIDES } from './popover.tokens'
|
||||
|
||||
const ownFrame = (height = 420) => ({ docs: { story: { inline: false, iframeHeight: height } } })
|
||||
|
||||
const meta = {
|
||||
title: 'Overlays/Popover',
|
||||
component: Popover,
|
||||
tags: ['autodocs'],
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component:
|
||||
'Interactive content anchored to a trigger, on Base UI Popover. Opens on click, flips to stay on screen, and closes on Escape or an outside click with focus returning to the trigger. Use it for small forms, filters and details; for short non-interactive hints use Tooltip.',
|
||||
},
|
||||
},
|
||||
},
|
||||
argTypes: {
|
||||
title: { control: 'text' },
|
||||
description: { control: 'text' },
|
||||
label: { control: 'text' },
|
||||
side: { control: 'inline-radio', options: POPUP_SIDES, table: { defaultValue: { summary: 'bottom' } } },
|
||||
align: { control: 'inline-radio', options: POPUP_ALIGNS, table: { defaultValue: { summary: 'center' } } },
|
||||
sideOffset: { control: { type: 'number', min: 0, max: 32 }, table: { defaultValue: { summary: '8' } } },
|
||||
arrow: { control: 'boolean' },
|
||||
width: { control: 'number', table: { defaultValue: { summary: '320' } } },
|
||||
open: { control: 'boolean' },
|
||||
defaultOpen: { control: 'boolean' },
|
||||
modal: { control: 'boolean' },
|
||||
className: { control: 'text' },
|
||||
trigger: { control: false },
|
||||
children: { control: false },
|
||||
onOpenChange: { control: false },
|
||||
},
|
||||
args: {
|
||||
title: 'Notifications',
|
||||
description: 'You’re all caught up.',
|
||||
side: 'bottom',
|
||||
align: 'center',
|
||||
sideOffset: 8,
|
||||
arrow: false,
|
||||
width: 320,
|
||||
trigger: (
|
||||
<Button variant="outline" color="neutral" startIcon={<Bell aria-hidden="true" />}>
|
||||
Notifications
|
||||
</Button>
|
||||
),
|
||||
onOpenChange: fn(),
|
||||
},
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<div className="flex min-h-80 items-start justify-center pt-4">
|
||||
<Story />
|
||||
</div>
|
||||
),
|
||||
],
|
||||
} satisfies Meta<typeof Popover>
|
||||
|
||||
export default meta
|
||||
type Story = StoryObj<typeof meta>
|
||||
|
||||
export const Playground: Story = {}
|
||||
|
||||
export const Open: Story = {
|
||||
args: {
|
||||
defaultOpen: true,
|
||||
arrow: true,
|
||||
width: 380,
|
||||
title: 'Share link',
|
||||
description: 'Anyone at Acme Corporation with the link can view this project.',
|
||||
trigger: (
|
||||
<Button variant="outline" color="neutral" startIcon={<Link2 aria-hidden="true" />}>
|
||||
Share
|
||||
</Button>
|
||||
),
|
||||
children: (
|
||||
<div className="flex gap-2">
|
||||
<Input aria-label="Project link" readOnly defaultValue="https://example.com/p/acme-website" className="min-w-0 flex-1" />
|
||||
<Popover.Close render={<Button />}>Copy</Popover.Close>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
parameters: ownFrame(),
|
||||
}
|
||||
|
||||
export const WithForm: Story = {
|
||||
args: {
|
||||
defaultOpen: true,
|
||||
align: 'start',
|
||||
title: 'Dimensions',
|
||||
description: 'Set the size of the selected layer.',
|
||||
width: 300,
|
||||
trigger: <IconButton variant="outline" aria-label="Layer dimensions" icon={<SlidersHorizontal />} />,
|
||||
children: (
|
||||
<form className="flex flex-col gap-3" onSubmit={(event) => event.preventDefault()}>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<Input label="Width" defaultValue="1280" endAddon="px" size="sm" />
|
||||
<Input label="Height" defaultValue="720" endAddon="px" size="sm" />
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Popover.Close render={<Button size="sm" variant="ghost" color="neutral" />}>Cancel</Popover.Close>
|
||||
<Popover.Close render={<Button size="sm" type="submit" />}>Apply</Popover.Close>
|
||||
</div>
|
||||
</form>
|
||||
),
|
||||
},
|
||||
parameters: ownFrame(),
|
||||
}
|
||||
|
||||
export const Sides: Story = {
|
||||
parameters: {
|
||||
...ownFrame(460),
|
||||
docs: { ...ownFrame(460).docs, description: { story: 'Each side, open. A popover flips when the preferred side has no room.' } },
|
||||
},
|
||||
render: (args) => (
|
||||
<div className="mx-auto grid w-fit grid-cols-3 grid-rows-3 place-items-center gap-x-56 gap-y-24 py-6">
|
||||
{POPUP_SIDES.map((side) => (
|
||||
<div
|
||||
key={side}
|
||||
className={
|
||||
{ top: 'col-start-2 row-start-1', left: 'col-start-1 row-start-2', right: 'col-start-3 row-start-2', bottom: 'col-start-2 row-start-3' }[side]
|
||||
}
|
||||
>
|
||||
<Popover
|
||||
{...args}
|
||||
side={side}
|
||||
arrow
|
||||
width={170}
|
||||
defaultOpen
|
||||
title={undefined}
|
||||
description={undefined}
|
||||
label={`Popover on the ${side}`}
|
||||
trigger={
|
||||
<Button variant="outline" color="neutral">
|
||||
{side}
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<p className="m-0">Placed on the {side}.</p>
|
||||
</Popover>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Alignment: Story = {
|
||||
parameters: ownFrame(360),
|
||||
render: (args) => (
|
||||
<div className="flex w-full max-w-4xl justify-between pb-32">
|
||||
{POPUP_ALIGNS.map((align) => (
|
||||
<Popover
|
||||
key={align}
|
||||
{...args}
|
||||
align={align}
|
||||
defaultOpen
|
||||
width={200}
|
||||
title={`align="${align}"`}
|
||||
description={undefined}
|
||||
trigger={
|
||||
<Button variant="outline" color="neutral">
|
||||
{align}
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<p className="m-0 text-fg-muted">Lines up with the trigger’s {align}.</p>
|
||||
</Popover>
|
||||
))}
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Controlled: Story = {
|
||||
render: function Render(args) {
|
||||
const [open, setOpen] = useState(false)
|
||||
return (
|
||||
<div className="flex items-center gap-3">
|
||||
<Popover
|
||||
{...args}
|
||||
open={open}
|
||||
onOpenChange={setOpen}
|
||||
title="Schedule"
|
||||
description="Publish on Monday 6 October at 9:00."
|
||||
trigger={
|
||||
<Button variant="outline" color="neutral" startIcon={<CalendarDays aria-hidden="true" />}>
|
||||
Schedule
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<Button size="sm" onClick={() => setOpen(false)}>
|
||||
Confirm
|
||||
</Button>
|
||||
</Popover>
|
||||
<span className="text-sm text-fg-muted">open: {String(open)}</span>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user