12 lines
455 B
TypeScript
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
|
|
}
|