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:
thekhalidsha committed 2026-09-28 21:12:11 +05:30
1 parent dc5e6ff800
commit f01de83733
185 files changed
+22542 -5182

No files matched your search

+37 -28
View File
@@ -1,39 +1,48 @@
/**
* Switch style tokens.
*
* Kept in a separate module from the component so the file only exports
* components — mixing the two breaks Vite's fast refresh.
* Kept apart from Switch.tsx so that file only exports components (Vite fast
* refresh). Every entry is a complete, literal class string.
*
* Geometry: the track has 2px padding (`p-0.5`), so
* travel = track width - thumb width - 4px.
* sm: 36 - 16 - 4 = 16px (translate-x-4)
* md: 44 - 20 - 4 = 20px (translate-x-5)
* lg: 52 - 24 - 4 = 24px (translate-x-6)
*/
export type SwitchSize = 'sm' | 'md' | 'lg'
export type SwitchColor = 'blue' | 'red' | 'green' | 'yellow' | 'teal' | 'indigo' | 'purple' | 'pink'
import type { Color, Size } from '../lib/styles'
export type SwitchSizeData = {
/** Track pill. */
toggle: string
/** Knob, including its resting offset from the track edge. */
dot: string
/** Travel distance of the knob when checked. */
translate: string
export type SwitchSize = Size
export type SwitchColor = Color
export type SwitchLabelPosition = 'end' | 'start'
export const SWITCH_SIZES: Record<SwitchSize, { track: string; thumb: string; icon: string }> = {
sm: { track: 'h-5 w-9', thumb: 'size-4 data-checked:translate-x-4', icon: '[&_svg]:size-2.5' },
md: { track: 'h-6 w-11', thumb: 'size-5 data-checked:translate-x-5', icon: '[&_svg]:size-3' },
lg: { track: 'h-7 w-[3.25rem]', thumb: 'size-6 data-checked:translate-x-6', icon: '[&_svg]:size-3.5' },
}
/**
* Every knob sits on a fixed 0.25rem inset from the track edge, so it can never
* render outside the pill. Travel = trackWidth - knobWidth - (2 * inset).
*/
export const SWITCH_SIZES: Record<SwitchSize, SwitchSizeData> = {
sm: { toggle: 'w-10 h-6 shrink-0', dot: 'w-4 h-4 left-1', translate: 'translate-x-4' },
md: { toggle: 'w-12 h-7 shrink-0', dot: 'w-5 h-5 left-1', translate: 'translate-x-5' },
lg: { toggle: 'w-[3.75rem] h-8 shrink-0', dot: 'w-6 h-6 left-1', translate: 'translate-x-7' },
/** Pushes the label down so its first line is centred on the track. */
export const SWITCH_LABEL_OFFSET: Record<SwitchSize, string> = {
sm: 'pt-0',
md: 'pt-0.5',
lg: 'pt-0.5',
}
export const SWITCH_COLORS: Record<SwitchColor, string> = {
blue: 'bg-primary-500',
red: 'bg-red-500',
green: 'bg-green-500',
yellow: 'bg-yellow-500',
teal: 'bg-teal-500',
indigo: 'bg-indigo-500',
purple: 'bg-purple-500',
pink: 'bg-pink-500',
export const SWITCH_LABEL_SIZES: Record<SwitchSize, string> = {
sm: 'text-sm leading-5',
md: 'text-sm leading-5',
lg: 'text-base leading-6',
}
/** Track fill when on, and the colour of an icon inside the thumb when on. */
export const SWITCH_COLORS: Record<SwitchColor, { track: string; icon: string; thumb?: string }> = {
primary: { track: 'data-checked:bg-primary-500', icon: 'data-checked:text-primary-600' },
// In dark mode `fg` is light, so the thumb turns dark to stay visible.
neutral: { track: 'data-checked:bg-fg', icon: 'data-checked:text-fg', thumb: 'dark:data-checked:bg-surface' },
success: { track: 'data-checked:bg-success-600', icon: 'data-checked:text-success-700' },
warning: { track: 'data-checked:bg-warning-400', icon: 'data-checked:text-warning-800' },
danger: { track: 'data-checked:bg-danger-600', icon: 'data-checked:text-danger-700' },
info: { track: 'data-checked:bg-info-600', icon: 'data-checked:text-info-700' },
}