import { isPaletteColor, PALETTE } from "@suphark/ui/lib/palette"; /** * ชุดสีเดิม 8 สี (ค่าที่แอปเก็บไว้แล้ว) — ใช้ token ของชุดสีป้ายกำกับ (`lib/palette`) ตั้งแต่ 0.80.0 จึงสลับ dark ให้เอง * ของใหม่ใช้ `PALETTE_COLORS` (20 สี) / `paletteClasses` / `LabelBadge` / `ColorSelect` แทน */ export type ColorName = "gray" | "red" | "yellow" | "green" | "blue" | "indigo" | "purple" | "pink"; export type ColorTheme = { background: string; text: string; }; function theme(color: keyof typeof PALETTE): ColorTheme { return { background: PALETTE[color].subtle.split(" ")[0] ?? "", text: PALETTE[color].text, }; } export const statusColorThemes: Record = { gray: theme("gray"), red: theme("red"), yellow: theme("yellow"), green: theme("green"), blue: theme("blue"), indigo: theme("indigo"), purple: theme("purple"), pink: theme("pink"), }; export const TAILWIND_COLORS: { name: ColorName; label: string }[] = [ { name: "gray", label: "Gray" }, { name: "red", label: "Red" }, { name: "yellow", label: "Yellow" }, { name: "green", label: "Green" }, { name: "blue", label: "Blue" }, { name: "indigo", label: "Indigo" }, { name: "purple", label: "Purple" }, { name: "pink", label: "Pink" }, ]; /** * theme สี (background + text) จากชื่อสี — รับทุกสีของชุดสีป้ายกำกับ 20 สี, ไม่รู้จัก = เทา */ export function getStatusColorTheme(color?: string | null): ColorTheme { return theme(isPaletteColor(color) ? color : "gray"); } /** class background + text รวมเป็น string เดียว */ export function getStatusColorClass(color?: string | null): string { const t = getStatusColorTheme(color); return `${t.background} ${t.text}`; }