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
+63
-117
@@ -10,10 +10,8 @@ src/data/catalogue.ts and writes /tmp/component_catalogue.json.
|
||||
python3 scripts/gen_catalogue.py # print entries
|
||||
python3 scripts/gen_catalogue.py --patch # also rewrite src/data/catalogue.ts
|
||||
|
||||
Story ids are `<group>-<component>--<story>`, but the group is not always
|
||||
a single segment: TextField publishes as `data-entry-text-field--*`. So
|
||||
components are matched by longest known name against `base` or
|
||||
`base.endswith("-" + name)`, with aliases for the hyphenated spellings.
|
||||
Components are read from story titles (`Group/Name`), so a new component
|
||||
appears here without editing this script; only DETAIL is hand-written.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -28,92 +26,50 @@ IDX = REPO / "storybook-static" / "index.json"
|
||||
CATALOGUE = REPO / "src" / "data" / "catalogue.ts"
|
||||
OUT = Path("/tmp/component_catalogue.json")
|
||||
|
||||
# component id -> group slug
|
||||
GROUPS = {
|
||||
"button": "actions",
|
||||
"accordion": "navigation",
|
||||
"text-field": "data-entry",
|
||||
"textfield": "data-entry",
|
||||
"input": "forms",
|
||||
"featuredinput": "forms",
|
||||
"featured-input": "forms",
|
||||
"select": "forms",
|
||||
"checkbox": "forms",
|
||||
"radio": "forms",
|
||||
"switch": "forms",
|
||||
"textarea": "forms",
|
||||
"text-area": "forms",
|
||||
"alert": "feedback",
|
||||
"spinner": "feedback",
|
||||
"badge": "display",
|
||||
"card": "layout",
|
||||
"tooltip": "overlays",
|
||||
}
|
||||
# Group order on the landing page; matches the Storybook sidebar.
|
||||
GROUP_ORDER = ["Actions", "Forms", "Overlays", "Navigation", "Feedback", "Display", "Layout"]
|
||||
|
||||
# alias id key -> canonical component key
|
||||
CANON = {
|
||||
"text-field": "textfield",
|
||||
"featured-input": "featuredinput",
|
||||
"text-area": "textarea",
|
||||
}
|
||||
|
||||
SPECIAL = {
|
||||
"textfield": "Text field",
|
||||
"featuredinput": "FeaturedInput",
|
||||
"textarea": "TextArea",
|
||||
"checkbox": "Checkbox",
|
||||
"spinner": "Spinner",
|
||||
"accordion": "Accordion",
|
||||
"tooltip": "Tooltip",
|
||||
"button": "Button",
|
||||
"select": "Select",
|
||||
"radio": "Radio",
|
||||
"switch": "Switch",
|
||||
"alert": "Alert",
|
||||
"badge": "Badge",
|
||||
"card": "Card",
|
||||
"input": "Input",
|
||||
}
|
||||
|
||||
GROUP_LABEL = {
|
||||
"actions": "Actions",
|
||||
"navigation": "Navigation",
|
||||
"data": "Data entry",
|
||||
"data-entry": "Data entry",
|
||||
"forms": "Forms",
|
||||
"feedback": "Feedback",
|
||||
"display": "Display",
|
||||
"layout": "Layout",
|
||||
"overlays": "Overlays",
|
||||
"misc": "Other",
|
||||
}
|
||||
|
||||
# display order on the landing page
|
||||
ORDER = [
|
||||
"button", "accordion", "textfield",
|
||||
"input", "featuredinput", "select", "checkbox", "radio", "switch", "textarea",
|
||||
"alert", "spinner",
|
||||
"badge", "card",
|
||||
"tooltip",
|
||||
]
|
||||
|
||||
# one-line coverage summary shown in the index row
|
||||
# One-line coverage summary per component. Anything missing falls back to
|
||||
# its story count, so a new component never breaks the generator.
|
||||
DETAIL = {
|
||||
"button": "Variants · sizes · disabled",
|
||||
"accordion": "Disclosure · multiple",
|
||||
"textfield": "Labels · hints · errors",
|
||||
"input": "Plain · themed · icon slot",
|
||||
"featuredinput": "Floating label · password · number",
|
||||
"select": "Searchable · featured · async",
|
||||
"checkbox": "Themes · tooltip · uncontrolled",
|
||||
"radio": "Themes · horizontal · required",
|
||||
"switch": "Themes · required · described",
|
||||
"textarea": "Resize · featured · prefilled",
|
||||
"alert": "Variants · colors · auto-close",
|
||||
"spinner": "Sizes · variants · dark",
|
||||
"badge": "Colors · floating · pulse",
|
||||
"card": "Themes · shadows · horizontal",
|
||||
"tooltip": "Positions · rich content · sizes",
|
||||
"Button": "Variants · colours · loading · icons",
|
||||
"ToggleGroup": "Segmented · multiple · icon-only",
|
||||
"Input": "Addons · icons · filled · underline",
|
||||
"FeaturedInput": "Floating label · password · clearable",
|
||||
"TextArea": "Auto-resize · character count",
|
||||
"FeaturedTextArea": "Floating label · auto-resize",
|
||||
"NumberInput": "Steppers · currency · min/max",
|
||||
"Field": "Label · description · error wiring",
|
||||
"Select": "Single · multiple · grouped · clearable",
|
||||
"FeaturedSelect": "Floating label · searchable · actions",
|
||||
"Combobox": "Search · chips · async",
|
||||
"NativeSelect": "Native menu · groups",
|
||||
"Checkbox": "Indeterminate · colours · sizes",
|
||||
"CheckboxGroup": "Select all · horizontal",
|
||||
"Radio": "Cards · horizontal · descriptions",
|
||||
"Switch": "Icons · label position · colours",
|
||||
"Slider": "Range · marks · formatted",
|
||||
"Dialog": "Sizes · scrolling body · forms",
|
||||
"AlertDialog": "Destructive · async confirm",
|
||||
"Drawer": "Four sides · sizes",
|
||||
"Popover": "Sides · arrow · rich content",
|
||||
"Tooltip": "Sides · colours · InfoTip",
|
||||
"DropdownMenu": "Shortcuts · submenus · checkable",
|
||||
"Tabs": "Underline · pills · vertical",
|
||||
"Accordion": "Multiple · variants · heading level",
|
||||
"Breadcrumb": "Collapse · icons",
|
||||
"Pagination": "Siblings · boundaries · sizes",
|
||||
"Alert": "Soft · solid · outline · dismissible",
|
||||
"Toast": "Promise · actions · placement",
|
||||
"Spinner": "Sizes · colours",
|
||||
"Progress": "Indeterminate · meter · formatted",
|
||||
"Skeleton": "Text · circle · card loading",
|
||||
"Badge": "Colours · dot · removable · count",
|
||||
"Avatar": "Initials · status · groups",
|
||||
"Kbd": "Key combinations",
|
||||
"Table": "Sortable · striped · sticky header",
|
||||
"Card": "Outline · elevated · media · link",
|
||||
"Separator": "Labelled · dashed · vertical",
|
||||
}
|
||||
|
||||
|
||||
@@ -121,41 +77,31 @@ def collect():
|
||||
if not IDX.is_file():
|
||||
sys.exit(f"{IDX} not found - run: npm run build-storybook")
|
||||
|
||||
entries = json.loads(IDX.read_text())["entries"]
|
||||
ids = [v.get("id", k) if isinstance(v, dict) else k for k, v in entries.items()]
|
||||
|
||||
entries = json.loads(IDX.read_text())["entries"].values()
|
||||
comps: dict[str, dict] = {}
|
||||
for sid in ids:
|
||||
if "--" not in sid:
|
||||
continue
|
||||
base, story = sid.split("--", 1)
|
||||
comp = next(
|
||||
(CANON.get(c, c) for c in sorted(GROUPS, key=len, reverse=True)
|
||||
if base == c or base.endswith("-" + c)),
|
||||
None,
|
||||
)
|
||||
if comp is None:
|
||||
print(f" WARN unmapped story id: {sid}", file=sys.stderr)
|
||||
continue
|
||||
g = comps.setdefault(comp, {"group": GROUPS[comp], "doc": None,
|
||||
"count": 0})
|
||||
g["count"] += 1
|
||||
if story in ("documentation", "docs"):
|
||||
g["doc"] = sid
|
||||
for e in entries:
|
||||
group, _, name = e["title"].partition("/")
|
||||
if not name or group not in GROUP_ORDER:
|
||||
continue # Introduction pages and anything outside the component groups
|
||||
c = comps.setdefault(name, {"group": group, "doc": None, "count": 0})
|
||||
if e["type"] == "docs":
|
||||
c["doc"] = e["id"]
|
||||
else:
|
||||
c["count"] += 1
|
||||
|
||||
ordered = sorted(comps.items(), key=lambda kv: (GROUP_ORDER.index(kv[1]["group"]), kv[0].lower()))
|
||||
out = []
|
||||
for i, comp in enumerate(ORDER, start=1):
|
||||
g = comps.get(comp)
|
||||
if not g or not g["doc"]:
|
||||
print(f" WARN {comp}: no documentation story, skipped", file=sys.stderr)
|
||||
for i, (name, c) in enumerate(ordered, start=1):
|
||||
if not c["doc"]:
|
||||
print(f" WARN {name}: no documentation page, skipped", file=sys.stderr)
|
||||
continue
|
||||
out.append({
|
||||
"number": f"{i:02d}",
|
||||
"group": GROUP_LABEL.get(g["group"], g["group"].title()),
|
||||
"name": SPECIAL.get(comp, comp.title()),
|
||||
"detail": DETAIL.get(comp, f"{g['count']} stories"),
|
||||
"href": f"/docs/?path=/docs/{g['doc']}",
|
||||
"count": g["count"],
|
||||
"group": c["group"],
|
||||
"name": name,
|
||||
"detail": DETAIL.get(name, f"{c['count']} stories"),
|
||||
"href": f"/docs/?path=/docs/{c['doc']}",
|
||||
"count": c["count"],
|
||||
})
|
||||
return out
|
||||
|
||||
|
||||
Reference in new issue
Block a user