import type { ReactNode } from "react"; import { CircleAlert, CircleCheck, TriangleAlert } from "lucide-react"; /** * Genesis MessageBar ของ wordaddin — แทน MessageBar ของ Fluent UI v9 ต้นฉบับ * intent error = ข้อความ/ไอคอนใช้เฉด -ink (contrast ≥5:1 ตาม DESIGN.md), พื้น tint จาง * มี icon นำตามระดับ — แยกด้วยรูปทรง ไม่ใช่สีอย่างเดียว (WCAG 1.4.1) + role ให้ screen * reader ประกาศ (error = alert, ที่เหลือ = status polite — WCAG 4.1.3) + w-full ให้ทุก * แถบกว้างเท่ากันทั้งคอลัมน์ * prop action = ปุ่มเสริมในแถบ (เช่น "ลองใหม่" ของ bootError/history error) */ const ICONS = { error: CircleAlert, warning: TriangleAlert, success: CircleCheck, } as const; export function MessageBar({ intent, children, action, }: { intent: "error" | "warning" | "success"; children: ReactNode; action?: ReactNode; }) { const Icon = ICONS[intent]; const tone = intent === "error" ? "border-error/30 bg-error/10 text-error-ink" : intent === "warning" ? "border-warning/30 bg-warning/15 text-warning-ink" : "border-success/30 bg-success/10 text-success-ink"; return (