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
+35
-48
@@ -1,52 +1,36 @@
|
||||
import { useEffect, useRef, type ReactElement } from 'react'
|
||||
import type { Decorator, Preview } from '@storybook/react-vite'
|
||||
import '../src/index.css'
|
||||
import { applyPalette } from '../src/theme/applyPalette'
|
||||
import { palettes, DEFAULT_PALETTE, type PaletteName } from '../src/theme/palettes'
|
||||
import { tansyTheme } from './tansyTheme'
|
||||
import { ThemeSurface } from './ThemeSurface'
|
||||
|
||||
/**
|
||||
* Wraps every story in a themed surface.
|
||||
*
|
||||
* The palette globals are set on this wrapper rather than on
|
||||
* `document.documentElement` so a story can opt into a *different* palette on
|
||||
* its own subtree without fighting the global one, and so the docs page keeps
|
||||
* its own chrome.
|
||||
*
|
||||
* Declared as a named component (not an inline arrow) so the rules-of-hooks lint
|
||||
* recognises the hook calls below.
|
||||
*/
|
||||
function PaletteSurface({ palette, children }: { palette: PaletteName; children: ReactElement }) {
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (ref.current) applyPalette(ref.current, palette)
|
||||
}, [palette])
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
data-palette={palette}
|
||||
style={{
|
||||
padding: '1.5rem',
|
||||
minHeight: '100%',
|
||||
color: 'var(--color-gray-900)',
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const withPalette: Decorator = (Story, context) => {
|
||||
const withTheme: Decorator = (Story, context) => {
|
||||
const palette = (context.globals.palette ?? DEFAULT_PALETTE) as PaletteName
|
||||
return <PaletteSurface palette={palette}><Story /></PaletteSurface>
|
||||
const mode = context.globals.mode === 'dark' ? 'dark' : 'light'
|
||||
const padded = context.parameters.layout !== 'fullscreen'
|
||||
return (
|
||||
<ThemeSurface palette={palette} mode={mode} padded={padded}>
|
||||
<Story />
|
||||
</ThemeSurface>
|
||||
)
|
||||
}
|
||||
|
||||
const preview: Preview = {
|
||||
title: 'Tansy UI / Component Workshop',
|
||||
decorators: [withPalette],
|
||||
decorators: [withTheme],
|
||||
globalTypes: {
|
||||
mode: {
|
||||
description: 'Light or dark mode for every component and popup.',
|
||||
toolbar: {
|
||||
title: 'Mode',
|
||||
icon: 'contrast',
|
||||
items: [
|
||||
{ value: 'light', title: 'Light', icon: 'sun' },
|
||||
{ value: 'dark', title: 'Dark', icon: 'moon' },
|
||||
],
|
||||
dynamicTitle: true,
|
||||
},
|
||||
},
|
||||
palette: {
|
||||
description: 'Brand palette applied to every element in the canvas.',
|
||||
toolbar: {
|
||||
@@ -61,28 +45,31 @@ const preview: Preview = {
|
||||
},
|
||||
},
|
||||
initialGlobals: {
|
||||
mode: 'light',
|
||||
palette: DEFAULT_PALETTE,
|
||||
},
|
||||
parameters: {
|
||||
backgrounds: { disable: true },
|
||||
docs: {
|
||||
theme: tansyTheme,
|
||||
},
|
||||
options: {
|
||||
storySort: {
|
||||
order: ['Welcome', 'Actions', 'Forms', 'Data entry', 'Feedback', 'Display', 'Layout', 'Navigation', 'Overlays'],
|
||||
order: [
|
||||
'Introduction',
|
||||
['Welcome', 'Getting started', 'Theming', 'Accessibility', 'Changelog', 'Roadmap'],
|
||||
'Actions',
|
||||
'Forms',
|
||||
'Feedback',
|
||||
'Display',
|
||||
'Layout',
|
||||
'Navigation',
|
||||
'Overlays',
|
||||
],
|
||||
},
|
||||
},
|
||||
backgrounds: {
|
||||
default: 'showcase',
|
||||
values: [
|
||||
{ name: 'showcase', value: '#f3f4f6' },
|
||||
{ name: 'surface', value: '#ffffff' },
|
||||
{ name: 'dark', value: '#12151c' },
|
||||
],
|
||||
},
|
||||
controls: {
|
||||
matchers: {
|
||||
color: /(background|color)$/i,
|
||||
date: /Date$/i,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user