feat(design): add IMS Admin primitives (Button, StatusTag, Checkbox, FilterChip, Segmented, Avatar, Drawer) and restyle Field, Card, Modal

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 09:28:34 +08:00
co-authored by Claude Haiku 4.5
parent 01343d732e
commit 2a5b9332c7
15 changed files with 417 additions and 248 deletions
+43 -55
View File
@@ -1,72 +1,60 @@
import type { ReactNode } from 'react'
import {
AlarmClock,
BadgeCheck,
Circle,
CircleAlert,
CircleCheck,
ClipboardList,
ListChecks,
Loader,
RotateCcw,
Search,
type LucideIcon,
} from 'lucide-react'
import { Tag, type TagVariant } from './tag'
import { cx } from './cx'
const TONES: Record<string, TagVariant> = {
reported: 'accent',
triaged: 'outline',
investigating: 'outline',
capa_pending: 'outline',
verification: 'outline',
closed: 'neutral',
open: 'accent',
in_progress: 'outline',
overdue: 'accent',
pending_verification: 'outline',
verified: 'neutral',
reopened: 'accent',
export type StatusHue = 'amber' | 'blue' | 'violet' | 'orange' | 'indigo' | 'green' | 'grey' | 'red'
const HUES: Record<string, StatusHue> = {
reported: 'amber', triaged: 'blue', investigating: 'violet', capa_pending: 'orange',
verification: 'indigo', closed: 'green',
open: 'grey', in_progress: 'blue', overdue: 'red', pending_verification: 'indigo',
verified: 'green', reopened: 'red',
critical: 'red', high: 'orange', med: 'amber', medium: 'amber', low: 'grey', active: 'green',
}
const ICONS: Record<string, LucideIcon> = {
reported: CircleAlert,
triaged: ListChecks,
investigating: Search,
capa_pending: ClipboardList,
verification: BadgeCheck,
closed: CircleCheck,
open: Circle,
in_progress: Loader,
overdue: AlarmClock,
pending_verification: BadgeCheck,
verified: CircleCheck,
reopened: RotateCcw,
const LABELS: Record<string, string> = {
capa_pending: 'CAPA pending', pending_verification: 'Verification', in_progress: 'In progress', med: 'Medium',
}
export function statusTone(status: string): TagVariant {
return TONES[status] ?? 'neutral'
// Full literal class strings so Tailwind can see them.
const HUE_CLASS: Record<StatusHue, string> = {
amber: 'bg-st-amber-bg text-st-amber-fg',
blue: 'bg-st-blue-bg text-st-blue-fg',
violet: 'bg-st-violet-bg text-st-violet-fg',
orange: 'bg-st-orange-bg text-st-orange-fg',
indigo: 'bg-st-indigo-bg text-st-indigo-fg',
green: 'bg-st-green-bg text-st-green-fg',
grey: 'bg-st-grey-bg text-st-grey-fg',
red: 'bg-st-red-bg text-st-red-fg',
}
function humanize(value: string): string {
return value
.split('_')
.map(w => (w === 'capa' ? 'CAPA' : w.charAt(0).toUpperCase() + w.slice(1)))
.join(' ')
export function statusHue(key: string): StatusHue {
return HUES[key] ?? 'grey'
}
export function StatusTag({ status, children }: { status: string; children?: ReactNode }) {
const Icon = ICONS[status]
function label(key: string): string {
if (LABELS[key]) return LABELS[key]
const words = key.split('_').join(' ')
return words.charAt(0).toUpperCase() + words.slice(1)
}
function Pill({ hue, className, children }: { hue: StatusHue; className?: string; children: ReactNode }) {
return (
<Tag variant={statusTone(status)}>
{Icon && <Icon size={12} strokeWidth={2} aria-hidden />}
{children ?? humanize(status)}
</Tag>
<span
className={cx(
'inline-flex items-center px-2 py-0.5 rounded-md text-xs font-[550] whitespace-nowrap',
HUE_CLASS[hue],
className,
)}
>
{children}
</span>
)
}
const PRIORITY_TONES: Record<string, TagVariant> = { high: 'accent', med: 'outline', low: 'neutral' }
export function StatusTag({ status, children }: { status: string; children?: ReactNode }) {
return <Pill hue={statusHue(status)}>{children ?? label(status)}</Pill>
}
export function PriorityTag({ priority, children }: { priority: string; children?: ReactNode }) {
return <Tag variant={PRIORITY_TONES[priority] ?? 'neutral'}>{children ?? humanize(priority)}</Tag>
return <Pill hue={statusHue(priority)}>{children ?? label(priority)}</Pill>
}