ultisuite-client/lib/nav-color.ts
2026-05-25 13:52:40 +02:00

12 lines
455 B
TypeScript

/** Default Tailwind `bg-*` for new labels / folders (sidebar + settings). */
export const DEFAULT_NAV_COLOR = "bg-blue-500"
/** Normalize API or legacy hex values to a sidebar `bg-*` class. */
export function normalizeNavColorClass(color: string | undefined): string {
const c = (color ?? "").trim()
if (!c) return "bg-gray-500"
if (c.startsWith("bg-")) return c
if (/^#[\da-fA-F]{3,8}$/.test(c)) return `bg-[${c}]`
return DEFAULT_NAV_COLOR
}