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
@@ -19,42 +19,53 @@ Every part ships with:
|
||||
- **Its states.** Error, disabled, loading and required are part of the component, and each has its own story.
|
||||
- **Tokens, not hex codes.** Colours come from a 50–900 palette ramp, so switching the palette re-themes every part without a code change.
|
||||
|
||||
> **Status:** pre-release (v0.2.0). Tansy UI is not published to npm yet. It is developed in this repository, with a landing page and a Storybook workshop as its showcase.
|
||||
> **Status:** pre-release (v0.3.0). Tansy UI builds as a library (`npm run build:lib`) but is not published to npm yet. It is developed in this repository, with a landing page and a Storybook workshop as its showcase.
|
||||
|
||||
## Components
|
||||
|
||||
Built on [Base UI](https://base-ui.com) for accessible behaviour, styled with Tailwind CSS v4.
|
||||
|
||||
| Group | Components |
|
||||
|---|---|
|
||||
| Actions | `Button`, `LinkButton` |
|
||||
| Forms | `Input`, `FeaturedInput`, `Select`, `Checkbox`, `Radio`, `Switch`, `TextArea` |
|
||||
| Data entry | `TextField` |
|
||||
| Feedback | `Alert`, `Spinner` |
|
||||
| Display | `Badge` |
|
||||
| Layout | `Card` (with `Card.Header`, `Card.Title`, `Card.Body`, `Card.Footer`) |
|
||||
| Navigation | `Accordion` |
|
||||
| Overlays | `Tooltip` |
|
||||
| Actions | `Button`, `IconButton`, `LinkButton`, `ToggleGroup`, `Toggle` |
|
||||
| Forms | `Field`, `Input`, `FeaturedInput`, `TextArea`, `FeaturedTextArea`, `NumberInput`, `Select`, `FeaturedSelect`, `Combobox`, `NativeSelect`, `Checkbox`, `CheckboxGroup`, `Radio`, `Switch`, `Slider` |
|
||||
| Overlays | `Dialog` (`Modal`), `AlertDialog`, `Drawer` (`Sheet`), `Popover`, `Tooltip`, `InfoTip`, `DropdownMenu` |
|
||||
| Navigation | `Tabs`, `Accordion`, `Breadcrumb`, `Pagination` |
|
||||
| Feedback | `Alert`, `Toast` (`Toaster`, `useToast`), `Spinner`, `Progress`, `Meter`, `Skeleton` |
|
||||
| Display | `Badge`, `CountBadge`, `Avatar`, `AvatarGroup`, `Kbd`, `Table` |
|
||||
| Layout | `Card`, `Separator` |
|
||||
|
||||
Each component lives in `src/components/` with its style maps in a sibling `*.tokens.ts` and its stories in `*.stories.tsx`.
|
||||
Every component follows one API (see [`docs/CONVENTIONS.md`](docs/CONVENTIONS.md)):
|
||||
|
||||
- `color` for meaning and `variant` for style;
|
||||
- `size` of `sm`, `md` or `lg`;
|
||||
- `startIcon` and `endIcon` as React nodes;
|
||||
- `label`, `description` and `error` on every field;
|
||||
- `value`, `defaultValue` and `onValueChange` for anything with a value.
|
||||
|
||||
## Usage
|
||||
|
||||
```css
|
||||
/* app.css */
|
||||
@import "tailwindcss";
|
||||
@import "tansy-ui/tokens.css";
|
||||
@source "../node_modules/tansy-ui/dist-lib";
|
||||
```
|
||||
|
||||
```tsx
|
||||
import { useState } from 'react'
|
||||
import { Button } from './components/Button'
|
||||
import { FeaturedInput } from './components/FeaturedInput'
|
||||
import { Switch } from './components/Switch'
|
||||
import { Mail } from 'lucide-react'
|
||||
import { Button, FeaturedInput, Select, Switch } from 'tansy-ui'
|
||||
|
||||
export function InviteForm() {
|
||||
const [email, setEmail] = useState('')
|
||||
|
||||
return (
|
||||
<form>
|
||||
<FeaturedInput
|
||||
label="Work email"
|
||||
type="email"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
required
|
||||
<form className="grid max-w-sm gap-5">
|
||||
<FeaturedInput label="Work email" type="email" startIcon={<Mail />} required />
|
||||
<Select
|
||||
label="Team"
|
||||
options={[
|
||||
{ value: 'design', label: 'Design' },
|
||||
{ value: 'engineering', label: 'Engineering' },
|
||||
]}
|
||||
/>
|
||||
<Switch label="Send a welcome email" defaultChecked />
|
||||
<Button type="submit">Send invite</Button>
|
||||
@@ -63,6 +74,8 @@ export function InviteForm() {
|
||||
}
|
||||
```
|
||||
|
||||
**Dark mode:** add the `dark` class to `<html>`.
|
||||
|
||||
## Theming
|
||||
|
||||
Tansy UI ships seven palettes: Classic Blue (default), Emerald, Violet, Amber, Crimson, Slate and Teal. Each defines full `primary`, `secondary`, `gray` and `zink` ramps plus semantic colours in `src/theme/palettes.ts`.
|
||||
@@ -84,16 +97,30 @@ npm install
|
||||
npm run dev # landing page at http://localhost:5173
|
||||
npm run storybook # component workshop at http://localhost:6006
|
||||
npm run lint
|
||||
npm test # unit, keyboard and axe tests for every component
|
||||
npm run build # landing page -> dist/
|
||||
npm run build-storybook # workshop -> storybook-static/
|
||||
npm run build:lib # library -> dist-lib/ (ES modules, types, tokens.css)
|
||||
```
|
||||
|
||||
To check every story in a real browser (runtime errors and axe, including colour contrast):
|
||||
|
||||
```bash
|
||||
npm run build-storybook
|
||||
node scripts/check-stories.mjs --mode light
|
||||
node scripts/check-stories.mjs --mode dark
|
||||
python3 scripts/contact-sheet.py /tmp/tansy-story-check/light # screenshots to review
|
||||
```
|
||||
|
||||
### Adding a component
|
||||
|
||||
1. Add it under `src/components/`, with style maps in a sibling `*.tokens.ts`.
|
||||
2. Add a colocated `ComponentName.stories.tsx` that covers every meaningful state.
|
||||
3. Read colours from the palette ramps (`bg-primary-500`) so the palette switcher reaches it.
|
||||
4. Run `npm run build-storybook && python3 scripts/gen_catalogue.py --patch` to refresh the landing page catalogue.
|
||||
Follow [`docs/CONVENTIONS.md`](docs/CONVENTIONS.md). In short:
|
||||
|
||||
1. Build it on Base UI where it has behaviour, in `src/components/`, with style maps in a sibling `*.tokens.ts`.
|
||||
2. Use only the tokens (`bg-surface`, `text-fg`, `primary-*`, `danger-*` …), and check it in dark mode.
|
||||
3. Add `Name.stories.tsx` with controls for every prop and a story for every state, and `Name.test.tsx` with keyboard and axe checks.
|
||||
4. Export it from `src/index.ts`.
|
||||
5. Run `npm test`, the story check in both modes, then `python3 scripts/gen_catalogue.py --patch` to refresh the landing page catalogue.
|
||||
|
||||
## Versioning
|
||||
|
||||
@@ -117,16 +144,21 @@ python3 scripts/deploy.py # builds that commit and deploys it
|
||||
```text
|
||||
src/
|
||||
├── brand/TansyMark.tsx # Palette-aware logo
|
||||
├── components/ # Components, their tokens and their stories
|
||||
├── components/ # Components, their tokens, stories and tests
|
||||
├── data/catalogue.ts # Landing page catalogue (regenerated by scripts/gen_catalogue.py)
|
||||
├── docs/ # Storybook Introduction pages (MDX)
|
||||
├── lib/ # cn(), shared styles, useControllableState
|
||||
├── styles/tokens.css # Design tokens (shipped as tansy-ui/tokens.css)
|
||||
├── test/ # Vitest setup and the axe helper
|
||||
├── theme/ # Palettes and applyPalette()
|
||||
├── index.ts # Public API
|
||||
├── version.ts # VERSION, injected from package.json
|
||||
├── Welcome.mdx # Storybook welcome page
|
||||
├── App.tsx # Landing page, built only from Tansy components
|
||||
└── index.css # Tailwind entry, palette tokens, landing styles
|
||||
.storybook/ # Storybook config, Tansy theme, fonts
|
||||
└── index.css # Tailwind entry and landing styles
|
||||
.storybook/ # Storybook config, Tansy theme, light/dark and palette toolbars
|
||||
docs/ # CONVENTIONS.md, ROADMAP.md
|
||||
scripts/ # Deploy, catalogue, story check and contact sheets
|
||||
public/ # tansy-mark.svg and favicon.svg
|
||||
scripts/ # Deploy and catalogue scripts
|
||||
```
|
||||
|
||||
## Brand
|
||||
|
||||
Reference in new issue
Block a user