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,100 @@
|
||||
/**
|
||||
* Toast style tokens. Kept apart from Toast.tsx for Vite fast refresh.
|
||||
*
|
||||
* The stacking and swipe transforms follow Base UI's Toast docs: each toast
|
||||
* reads --toast-index, --toast-offset-y and the swipe variables Base UI sets.
|
||||
* Every entry is a complete, literal class string so Tailwind finds it.
|
||||
*/
|
||||
|
||||
import type { Color } from '../lib/styles'
|
||||
|
||||
export type ToastPlacement = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'
|
||||
export type ToastColor = Color
|
||||
/** `loading` is used by `toast.promise` while the promise is pending. */
|
||||
export type ToastType = ToastColor | 'loading'
|
||||
export type ToastSwipeDirection = 'up' | 'down' | 'left' | 'right'
|
||||
|
||||
export const TOAST_PLACEMENTS: ToastPlacement[] = [
|
||||
'top-left',
|
||||
'top-center',
|
||||
'top-right',
|
||||
'bottom-left',
|
||||
'bottom-center',
|
||||
'bottom-right',
|
||||
]
|
||||
export const TOAST_COLORS: ToastColor[] = ['neutral', 'primary', 'success', 'warning', 'danger', 'info']
|
||||
|
||||
export const TOAST_VIEWPORT_STYLES: Record<ToastPlacement, string> = {
|
||||
'top-left': 'fixed top-4 left-4 z-50 w-[calc(100vw-2rem)] sm:top-6 sm:left-6 sm:w-[22.5rem]',
|
||||
'top-center': 'fixed top-4 inset-x-0 z-50 mx-auto w-[calc(100vw-2rem)] sm:top-6 sm:w-[22.5rem]',
|
||||
'top-right': 'fixed top-4 right-4 z-50 w-[calc(100vw-2rem)] sm:top-6 sm:right-6 sm:w-[22.5rem]',
|
||||
'bottom-left': 'fixed bottom-4 left-4 z-50 w-[calc(100vw-2rem)] sm:bottom-6 sm:left-6 sm:w-[22.5rem]',
|
||||
'bottom-center': 'fixed bottom-4 inset-x-0 z-50 mx-auto w-[calc(100vw-2rem)] sm:bottom-6 sm:w-[22.5rem]',
|
||||
'bottom-right': 'fixed bottom-4 right-4 z-50 w-[calc(100vw-2rem)] sm:bottom-6 sm:right-6 sm:w-[22.5rem]',
|
||||
}
|
||||
|
||||
export const TOAST_SWIPE: Record<ToastPlacement, ToastSwipeDirection[]> = {
|
||||
'top-left': ['up', 'left'],
|
||||
'top-center': ['up'],
|
||||
'top-right': ['up', 'right'],
|
||||
'bottom-left': ['down', 'left'],
|
||||
'bottom-center': ['down'],
|
||||
'bottom-right': ['down', 'right'],
|
||||
}
|
||||
|
||||
/** Stack, enter, exit and swipe motion for toasts anchored to the bottom edge. */
|
||||
const bottomMotion =
|
||||
"[--gap:0.75rem] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))] [--height:var(--toast-frontmost-height,var(--toast-height))] " +
|
||||
'[--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y))] ' +
|
||||
'absolute inset-x-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom ' +
|
||||
'[transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] ' +
|
||||
"after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-[''] " +
|
||||
'data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--offset-y)))] ' +
|
||||
'data-starting-style:[transform:translateY(150%)] ' +
|
||||
'[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)] ' +
|
||||
'data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))] ' +
|
||||
'data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))] ' +
|
||||
'data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))] ' +
|
||||
'data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))] ' +
|
||||
'h-(--height) data-expanded:h-(--toast-height)'
|
||||
|
||||
/** The same motion mirrored for toasts anchored to the top edge. */
|
||||
const topMotion =
|
||||
"[--gap:0.75rem] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))] [--height:var(--toast-frontmost-height,var(--toast-height))] " +
|
||||
'[--offset-y:calc(var(--toast-offset-y)+(var(--toast-index)*var(--gap))+var(--toast-swipe-movement-y))] ' +
|
||||
'absolute inset-x-0 top-0 z-[calc(1000-var(--toast-index))] w-full origin-top ' +
|
||||
'[transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)+(var(--toast-index)*var(--peek))+(var(--shrink)*var(--height))))_scale(var(--scale))] ' +
|
||||
"after:absolute after:bottom-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-[''] " +
|
||||
'data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--offset-y)))] ' +
|
||||
'data-starting-style:[transform:translateY(-150%)] ' +
|
||||
'[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(-150%)] ' +
|
||||
'data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))] ' +
|
||||
'data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))] ' +
|
||||
'data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))] ' +
|
||||
'data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))] ' +
|
||||
'h-(--height) data-expanded:h-(--toast-height)'
|
||||
|
||||
export const TOAST_ROOT_MOTION: Record<'top' | 'bottom', string> = {
|
||||
top: topMotion,
|
||||
bottom: bottomMotion,
|
||||
}
|
||||
|
||||
export const toastSurface =
|
||||
'select-none rounded-xl border border-border bg-surface text-fg shadow-popup outline-hidden ' +
|
||||
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500 ' +
|
||||
'data-ending-style:opacity-0 data-limited:opacity-0 ' +
|
||||
'[transition:transform_0.5s_cubic-bezier(0.22,1,0.36,1),opacity_0.5s,height_0.15s] motion-reduce:[transition:opacity_0.2s]'
|
||||
|
||||
export const toastContent =
|
||||
'flex items-start gap-3 overflow-hidden p-4 transition-opacity duration-250 data-behind:opacity-0 data-expanded:opacity-100 motion-reduce:transition-none'
|
||||
|
||||
/** Icon colour per toast type. */
|
||||
export const TOAST_ICON_STYLES: Record<ToastType, string> = {
|
||||
neutral: 'text-fg-muted',
|
||||
primary: 'text-primary-600 dark:text-primary-400',
|
||||
success: 'text-success-600 dark:text-success-400',
|
||||
warning: 'text-warning-600 dark:text-warning-400',
|
||||
danger: 'text-danger-600 dark:text-danger-400',
|
||||
info: 'text-info-600 dark:text-info-400',
|
||||
loading: 'text-fg-muted',
|
||||
}
|
||||
Reference in new issue
Block a user