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.
76 lines
3.3 KiB
TypeScript
76 lines
3.3 KiB
TypeScript
/**
|
|
* Shared class strings, so every component draws focus, sizing, popups and
|
|
* field text the same way. Components import these instead of repeating
|
|
* utility soup. Keep every value a complete, literal class string: Tailwind
|
|
* finds classes by scanning source text.
|
|
*/
|
|
|
|
export type Size = 'sm' | 'md' | 'lg'
|
|
|
|
/** Semantic colours shared by every component that takes a `color` prop. */
|
|
export type Color = 'primary' | 'neutral' | 'success' | 'warning' | 'danger' | 'info'
|
|
|
|
export const COLORS: Color[] = ['primary', 'neutral', 'success', 'warning', 'danger', 'info']
|
|
export const SIZES: Size[] = ['sm', 'md', 'lg']
|
|
|
|
/**
|
|
* Visible keyboard focus. Put it on every interactive element.
|
|
* `outline-hidden`, not `outline-none`: in Tailwind v4 `outline-none` sets the
|
|
* outline *style* to none, and `focus-visible:outline-2` inherits it, so no
|
|
* ring would ever draw.
|
|
*/
|
|
export const focusRing =
|
|
'outline-hidden focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500'
|
|
|
|
/** Focus ring for a wrapper that contains the focused control (inputs with icons). */
|
|
export const focusWithinRing =
|
|
'has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-primary-500'
|
|
|
|
/** Heights shared by every control, so a Button sits flush with an Input. */
|
|
export const controlHeight: Record<Size, string> = {
|
|
sm: 'h-8 text-sm',
|
|
md: 'h-10 text-sm',
|
|
lg: 'h-12 text-base',
|
|
}
|
|
|
|
export const controlPaddingX: Record<Size, string> = {
|
|
sm: 'px-2.5',
|
|
md: 'px-3',
|
|
lg: 'px-4',
|
|
}
|
|
|
|
/** Icon size inside a control of each size. */
|
|
export const iconSize: Record<Size, string> = {
|
|
sm: '[&_svg]:size-3.5',
|
|
md: '[&_svg]:size-4',
|
|
lg: '[&_svg]:size-5',
|
|
}
|
|
|
|
/** The bordered box of a text control. Invalid state comes from aria-invalid or Base UI's data-invalid. */
|
|
export const controlBox =
|
|
'rounded-lg border border-border-strong bg-surface text-fg transition-colors ' +
|
|
'hover:border-fg-subtle ' +
|
|
'data-invalid:border-danger-500 aria-[invalid=true]:border-danger-500 ' +
|
|
'data-disabled:cursor-not-allowed data-disabled:opacity-55 disabled:cursor-not-allowed disabled:opacity-55'
|
|
|
|
/** Popups: menus, selects, popovers, dialogs. */
|
|
/** In dark mode popups sit a step lighter than the card behind them. */
|
|
export const popupSurface =
|
|
'rounded-xl border border-border bg-surface text-fg shadow-popup outline-hidden dark:bg-surface-muted'
|
|
|
|
/** Enter and exit motion for popups that grow from their trigger. */
|
|
export const popupMotion =
|
|
'origin-(--transform-origin) transition-[transform,opacity] duration-150 ease-out ' +
|
|
'data-starting-style:scale-95 data-starting-style:opacity-0 data-ending-style:scale-95 data-ending-style:opacity-0 ' +
|
|
'motion-reduce:transition-none'
|
|
|
|
/** A selectable row inside a menu, select or combobox list. */
|
|
export const listItem =
|
|
'flex cursor-default select-none items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-fg outline-none ' +
|
|
'data-highlighted:bg-surface-sunken data-disabled:pointer-events-none data-disabled:opacity-50'
|
|
|
|
export const labelText = 'text-sm font-medium text-fg'
|
|
export const descriptionText = 'text-xs leading-5 text-fg-muted'
|
|
export const errorText = 'text-xs font-medium leading-5 text-danger-700 dark:text-danger-400'
|
|
export const requiredMark = 'ml-0.5 text-danger-700 dark:text-danger-400'
|