feat(desktop): port the 15 design-system primitives (#14)

Verbatim port of the handoff primitives into components/ui/ — Icon,
Button, IconButton, Badge, Tag, Card, Tabs (core); Input, Select,
Checkbox, Radio, Switch (forms); Dialog, Toast, Tooltip (feedback).
Each keeps its injected token-referencing CSS byte-for-byte; the
handoff .d.ts contracts become the exported prop interfaces. Barrel at
components/ui/index.ts.

Adds a PrimitivesGallery (app root for now; real shell is P3-2) that
exercises every primitive with a light/dark toggle. Smoke suite asserts
the gallery, section coverage, theme flip, and dialog open/Escape;
screenshots captured for both themes. typecheck + 5 e2e green.

Closes P3-1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Croissant Le Doux
2026-07-08 12:12:00 -04:00
parent 96c2b8b1c2
commit 635025113c
19 changed files with 1247 additions and 31 deletions

View File

@@ -0,0 +1,54 @@
import React from 'react'
import { Icon } from './icon.js'
/**
* Checkbox with label; 16px box, spruce when checked.
*/
export interface CheckboxProps {
label?: React.ReactNode;
checked?: boolean;
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
disabled?: boolean;
style?: React.CSSProperties;
}
const CSS = `
.ct-check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font: var(--text-body); color: var(--ink-1); }
.ct-check--disabled { opacity: 0.5; cursor: not-allowed; }
.ct-check__input { position: absolute; opacity: 0; width: 0; height: 0; }
.ct-check__box {
width: 16px; height: 16px; flex-shrink: 0;
display: inline-flex; align-items: center; justify-content: center;
background: var(--surface-card);
border: 1px solid var(--line-2);
border-radius: var(--radius-1);
color: transparent;
transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}
.ct-check:hover:not(.ct-check--disabled) .ct-check__box { border-color: var(--border-strong); }
.ct-check__input:checked + .ct-check__box { background: var(--accent); border-color: var(--accent); color: var(--ink-inverse); }
.ct-check__input:focus-visible + .ct-check__box { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
`;
(function inject() {
if (typeof document !== 'undefined' && !document.getElementById('ct-check-css')) {
const s = document.createElement('style'); s.id = 'ct-check-css'; s.textContent = CSS;
document.head.appendChild(s);
}
})();
export function Checkbox({ label, checked, onChange, disabled = false, style, ...rest }: CheckboxProps) {
return (
<label className={`ct-check${disabled ? ' ct-check--disabled' : ''}`} style={style}>
<input
type="checkbox"
className="ct-check__input"
checked={checked}
onChange={onChange}
disabled={disabled}
{...rest}
/>
<span className="ct-check__box"><Icon name="check" size={12} strokeWidth={2.5} /></span>
{label ? <span>{label}</span> : null}
</label>
);
}