feat(design): add Modernist UI primitives (Button, Tag, StatusTag, Field, Card, table styles)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-30 19:04:05 +08:00
co-authored by Claude Haiku 4.5
parent 3a941a357b
commit 4411ed54b5
9 changed files with 318 additions and 16 deletions
@@ -708,15 +708,15 @@ import { cx } from './cx'
type Variant = 'primary' | 'secondary' | 'ghost' | 'icon'
const BASE =
'inline-flex items-center justify-start gap-1.5 text-left font-extrabold text-sm leading-tight ' +
'inline-flex items-center gap-1.5 text-left font-extrabold text-sm leading-tight ' +
'border border-transparent cursor-pointer transition-colors ' +
'disabled:opacity-45 disabled:cursor-not-allowed'
const VARIANTS: Record<Variant, string> = {
primary: 'bg-accent text-ground px-3.5 py-2 hover:bg-accent-600 active:bg-accent-700',
secondary: 'border-divider text-ink px-3.5 py-2 hover:bg-ink/7 active:bg-ink/15',
ghost: 'text-accent px-1 py-2 hover:bg-accent/10 active:bg-accent/20',
icon: 'w-9 h-9 p-0 !justify-center text-ink hover:bg-ink/7 active:bg-ink/15',
primary: 'justify-start bg-accent text-ground px-3.5 py-2 hover:bg-accent-600 active:bg-accent-700',
secondary: 'justify-start border-divider text-ink px-3.5 py-2 hover:bg-ink/7 active:bg-ink/15',
ghost: 'justify-start text-accent-700 px-1 py-2 hover:bg-accent/10 active:bg-accent/20',
icon: 'justify-center w-9 h-9 p-0 text-ink hover:bg-ink/7 active:bg-ink/15',
}
type Props = ButtonHTMLAttributes<HTMLButtonElement> & {
@@ -725,20 +725,10 @@ type Props = ButtonHTMLAttributes<HTMLButtonElement> & {
}
export function Button({ variant = 'primary', block = false, className, type = 'button', ...rest }: Props) {
const isIcon = variant === 'icon'
return (
<button
type={type}
className={cx(BASE, VARIANTS[variant], block && 'w-full', className)}
{...rest}
data-icon={isIcon || undefined}
/>
)
return <button type={type} className={cx(BASE, VARIANTS[variant], block && 'w-full', className)} {...rest} />
}
```
Because the icon variant must be centered while `BASE` carries `justify-start`, the icon variant sets `!justify-center`. The test asserts the icon button's class list contains `justify-center`, which `!justify-center` satisfies as a substring.
`components/ui/tag.tsx`:
```tsx