พอร์ต taskpane ของ Word add-in "e-Court Documents Versioning" จาก D:\word-addin-poc มาเป็น sibling app ที่ route /docedit/wordaddin: - wordaddin/ (client-only zone): services พอร์ตดิบทั้งชุด (authService/versioningService เป็น mock รอ backend จริง) + models + config - components/wordaddin/: WordAddinGate ฉีด office.js self-host (singleton กัน StrictMode double-inject + fallback timer ครอบเคส onReady เงียบ) และ TaskpaneApp state machine แปลง JSX เป็น Genesis design system - scripts/fetch-office-js.mjs (postinstall ตัวที่สาม): ดาวน์โหลด Office.js runtime ล่าสุดจาก CDN Microsoft ไป public/wordaddin/office-js/ (gitignore สร้างใหม่ได้ — npm @microsoft/office-js ตกรุ่นไม่มี Document.close) - middleware/basePath/root page: เปิด /wordaddin เป็น public (auth แยกจาก แอป note), root /docedit redirect ไป taskpane ยกเว้นลิงก์ e-Court N8 (?fileUrl=&fileId=&typeId=) ที่ยังส่งต่อ /note ตามเดิม - docker/web.Dockerfile รัน fetch-office-js ตอน build + npm scripts dev:https สำหรับ sideload ตาม docs/WORDADDIN-DEV.md Co-Authored-By: Claude Code <noreply@anthropic.com>
45 lines
1.8 KiB
TypeScript
45 lines
1.8 KiB
TypeScript
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 (
|
|
<div
|
|
role={intent === "error" ? "alert" : "status"}
|
|
className={`flex w-full items-start gap-2 rounded-lg border px-3 py-2 text-sm ${tone}`}
|
|
>
|
|
<Icon className="mt-0.5 size-4 shrink-0" aria-hidden />
|
|
<div className="min-w-0 flex-1 break-words">{children}</div>
|
|
{action ? <div className="shrink-0">{action}</div> : null}
|
|
</div>
|
|
);
|
|
}
|