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:
@@ -0,0 +1,72 @@
|
||||
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'
|
||||
|
||||
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',
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
|
||||
export function statusTone(status: string): TagVariant {
|
||||
return TONES[status] ?? 'neutral'
|
||||
}
|
||||
|
||||
function humanize(value: string): string {
|
||||
return value
|
||||
.split('_')
|
||||
.map(w => (w === 'capa' ? 'CAPA' : w.charAt(0).toUpperCase() + w.slice(1)))
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
export function StatusTag({ status, children }: { status: string; children?: ReactNode }) {
|
||||
const Icon = ICONS[status]
|
||||
return (
|
||||
<Tag variant={statusTone(status)}>
|
||||
{Icon && <Icon size={12} strokeWidth={2} aria-hidden />}
|
||||
{children ?? humanize(status)}
|
||||
</Tag>
|
||||
)
|
||||
}
|
||||
|
||||
const PRIORITY_TONES: Record<string, TagVariant> = { high: 'accent', med: 'outline', low: 'neutral' }
|
||||
|
||||
export function PriorityTag({ priority, children }: { priority: string; children?: ReactNode }) {
|
||||
return <Tag variant={PRIORITY_TONES[priority] ?? 'neutral'}>{children ?? humanize(priority)}</Tag>
|
||||
}
|
||||
Reference in New Issue
Block a user