Files
ccs/ui/src/lib/utils.ts
T
kaitranntt f255a20a93 feat(analytics): refactor model color management and fix UI display issues
- Extract getModelColor utility to lib/utils.ts with improved FNV-1a hash algorithm
- Replace hardcoded color palette with vibrant tones palette
- Remove color constants from model-breakdown-chart.tsx
- Fix truncated model names in analytics display
- Update project roadmap with analytics enhancements
2025-12-09 14:44:56 -05:00

33 lines
828 B
TypeScript

import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function getModelColor(model: string): string {
// Vibrant Tones Palette
const colors = [
'#f94144', // Strawberry Red
'#f3722c', // Pumpkin Spice
'#f8961e', // Carrot Orange
'#f9844a', // Atomic Tangerine
'#f9c74f', // Tuscan Sun
'#90be6d', // Willow Green
'#43aa8b', // Seaweed
'#4d908e', // Dark Cyan
'#577590', // Blue Slate
'#277da1', // Cerulean
];
// FNV-1a hash algorithm
let hash = 0x811c9dc5;
for (let i = 0; i < model.length; i++) {
hash ^= model.charCodeAt(i);
hash = Math.imul(hash, 0x01000193);
}
// Ensure positive index
return colors[(hash >>> 0) % colors.length];
}