contiai / apps /web /src /lib /taskTint.ts
aliroya's picture
ContiAI platform: API and queue worker in one container (part 2)
2bb5af3 verified
Raw History Blame Contribute Delete
997 Bytes
/* One colour per task type, everywhere it appears.
The icon chip on the create grid, the eyebrow on a project card, the badge
in the library and the donut slice on the usage screen all agree, so "books
are ultramarine, bags are teal" becomes something the eye learns once.
The six colours are the CVD-verified viz series; known types get a stable
assignment and anything new falls back to a hash, so a type added on the
server still gets a consistent colour without touching this file. */
const ORDER: Record<string, number> = {
book: 0,
training_bag: 2,
course: 1,
level: 3,
references: 4,
appendix: 5,
};
function slot(key: string): number {
if (key in ORDER) return ORDER[key];
let h = 0;
for (const ch of key) h = (h * 31 + ch.charCodeAt(0)) % 997;
return h % 6;
}
export function taskColor(key: string): string {
return `var(--viz-${slot(key) + 1})`;
}
export function taskTintBg(key: string): string {
return `var(--tint-${slot(key) + 1})`;
}