返回 CodeWhale
status-badge.tsx
根目录 / web / components / status-badge.tsx
1 /**
2 * <StatusBadge> — honest availability labels for public surfaces.
3 *
4 * Used wherever the site shows something that is not a shipped, stable
5 * feature: experimental bridges, preview platforms, pending media, and
6 * unavailable states. The label is always visible text — never color alone —
7 * so the state is conveyed accessibly in both locales.
8 */
9
10 import type { LocalizedText } from "@/lib/content/vocabulary";
11 import { pickText } from "@/lib/i18n/dictionaries";
12
13 export type StatusKind = "experimental" | "preview" | "pending" | "unavailable";
14
15 const DEFAULT_LABELS: Record<StatusKind, LocalizedText> = {
16 experimental: { en: "Experimental", zh: "实验性" },
17 preview: { en: "Preview", zh: "预览" },
18 pending: { en: "Pending", zh: "待就绪" },
19 unavailable: { en: "Unavailable", zh: "暂不可用" },
20 };
21
22 export function StatusBadge({
23 kind,
24 locale = "en",
25 label,
26 }: {
27 kind: StatusKind;
28 locale?: string;
29 /** Overrides the default per-kind label (e.g. a media entry's pendingLabel). */
30 label?: LocalizedText;
31 }) {
32 const text = pickText(label ?? DEFAULT_LABELS[kind], locale);
33
34 return (
35 <span className={`status-badge status-badge-${kind}`}>
36 <span className="status-badge-dot" aria-hidden="true" />
37 {text}
38 </span>
39 );
40 }
41
41 lines Plain Text