Files
tansy-ui/src/components/display.fixtures.ts
T
thekhalidsha f01de83733 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.
2026-09-28 21:12:11 +05:30

81 lines
4.3 KiB
TypeScript

/**
* Sample data for the Display and Layout stories: portrait placeholders
* (inline SVG data URIs, so stories never depend on external images) and a
* small employee directory. Not part of the public API.
*/
import type { Color } from '../lib/styles'
/** A generated head-and-shoulders portrait on a two-tone gradient. */
export function portrait(from: string, to: string, skin = '#f1c7a6', hair = '#3b2a22'): string {
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96">
<defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="${from}"/><stop offset="1" stop-color="${to}"/></linearGradient></defs>
<rect width="96" height="96" fill="url(#g)"/>
<path d="M14 96c2-19 16-30 34-30s32 11 34 30z" fill="${to}" opacity=".55"/>
<path d="M18 96c3-16 15-25 30-25s27 9 30 25z" fill="#ffffff" opacity=".9"/>
<rect x="41" y="54" width="14" height="14" rx="6" fill="${skin}"/>
<circle cx="48" cy="42" r="17" fill="${skin}"/>
<path d="M30 42c-1-14 8-22 18-22s20 7 18 22c-3-7-8-11-18-11s-15 4-18 11z" fill="${hair}"/>
</svg>`
return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`
}
/** A wide landscape illustration for card media. */
export function landscape(sky: string, hills: string): string {
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 180" preserveAspectRatio="xMidYMid slice">
<defs><linearGradient id="s" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="${sky}"/><stop offset="1" stop-color="#ffffff"/></linearGradient></defs>
<rect width="320" height="180" fill="url(#s)"/>
<circle cx="236" cy="62" r="22" fill="#ffffff" opacity=".85"/>
<path d="M0 132 70 84l56 38 64-58 130 80v36H0z" fill="${hills}" opacity=".55"/>
<path d="M0 150 90 112l70 30 80-40 80 44v34H0z" fill="${hills}"/>
</svg>`
return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`
}
export const PORTRAITS = {
jane: portrait('#c7d7fe', '#6d8fe8', '#f1c7a6', '#5b3a29'),
john: portrait('#bbf7d0', '#34a47a', '#d9a47f', '#1f1a17'),
maya: portrait('#fde68a', '#e59a3b', '#b98262', '#141012'),
carlos: portrait('#fecaca', '#d9635f', '#c68e6b', '#2d211b'),
aiko: portrait('#bae6fd', '#3b9fd6', '#f3d2b8', '#101418'),
}
export type Employee = {
id: string
name: string
email: string
avatar?: string
department: 'Engineering' | 'Design' | 'Sales' | 'Operations' | 'Finance'
status: 'Active' | 'On leave' | 'Onboarding'
startDate: string
salary: number
}
export const DEPARTMENT_COLORS: Record<Employee['department'], Color> = {
Engineering: 'primary',
Design: 'info',
Sales: 'success',
Operations: 'warning',
Finance: 'neutral',
}
export const STATUS_COLORS: Record<Employee['status'], Color> = {
Active: 'success',
'On leave': 'warning',
Onboarding: 'info',
}
export const EMPLOYEES: Employee[] = [
{ id: 'E-1001', name: 'Jane Doe', email: '[email protected]', avatar: PORTRAITS.jane, department: 'Engineering', status: 'Active', startDate: '2021-03-15', salary: 128000 },
{ id: 'E-1002', name: 'John Smith', email: '[email protected]', avatar: PORTRAITS.john, department: 'Sales', status: 'Active', startDate: '2019-11-04', salary: 94500 },
{ id: 'E-1003', name: 'Maya Chen', email: '[email protected]', avatar: PORTRAITS.maya, department: 'Design', status: 'On leave', startDate: '2022-06-20', salary: 112000 },
{ id: 'E-1004', name: 'Carlos Mendez', email: '[email protected]', department: 'Operations', status: 'Active', startDate: '2018-01-08', salary: 87250 },
{ id: 'E-1005', name: 'Aiko Tanaka', email: '[email protected]', avatar: PORTRAITS.aiko, department: 'Engineering', status: 'Onboarding', startDate: '2026-09-01', salary: 136500 },
{ id: 'E-1006', name: 'Samuel Okafor', email: '[email protected]', department: 'Finance', status: 'Active', startDate: '2020-08-17', salary: 101800 },
{ id: 'E-1007', name: 'Lena Fischer', email: '[email protected]', department: 'Design', status: 'Active', startDate: '2023-02-27', salary: 99000 },
{ id: 'E-1008', name: 'Marcus Reed', email: '[email protected]', avatar: PORTRAITS.carlos, department: 'Sales', status: 'Active', startDate: '2024-04-10', salary: 82300 },
]
export const currency = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 })
export const shortDate = new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' })