import { cn } from "@/lib/utils";
// Fixed palette (full class strings so Tailwind picks them up). A tag's color is derived from its
// name, so the same tag has the same color everywhere without storing anything.
const PALETTE = [
"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",
"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",
"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",
"border-rose-500/30 bg-rose-500/10 text-rose-700 dark:text-rose-300",
"border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300",
"border-cyan-500/30 bg-cyan-500/10 text-cyan-700 dark:text-cyan-300",
"border-lime-500/30 bg-lime-500/10 text-lime-700 dark:text-lime-300",
"border-orange-500/30 bg-orange-500/10 text-orange-700 dark:text-orange-300",
"border-fuchsia-500/30 bg-fuchsia-500/10 text-fuchsia-700 dark:text-fuchsia-300",
"border-teal-500/30 bg-teal-500/10 text-teal-700 dark:text-teal-300",
];
const DOTS = [
"bg-sky-500",
"bg-emerald-500",
"bg-amber-500",
"bg-rose-500",
"bg-violet-500",
"bg-cyan-500",
"bg-lime-500",
"bg-orange-500",
"bg-fuchsia-500",
"bg-teal-500",
];
function colorIndex(name: string): number {
let h = 0;
for (const ch of name.trim().toLowerCase()) h = (h * 31 + ch.codePointAt(0)!) >>> 0;
return h % PALETTE.length;
}
export function tagColorClass(name: string): string {
return PALETTE[colorIndex(name)];
}
/** Small colored dot for a tag (e.g. in filter menus). */
export function TagDot({ name }: { name: string }) {
return ;
}
/** A user tag, colored by its name. */
export function TagBadge({
name,
className,
children,
}: {
name: string;
className?: string;
children?: React.ReactNode;
}) {
return (
{name}
{children}
);
}