import { colorIsDarkSimple } from "~/components/etichette"; import { Avatar, AvatarFallback } from "~/components/ui/avatar"; import { cn, getHexColorFromString, getInitials } from "~/lib/utils"; import type { UsersId } from "~/schemas/public/Users"; const colorOptions = new Map(); export const getUserColor = (str: string) => { if (colorOptions.has(str)) { // biome-ignore lint/style/noNonNullAssertion: return colorOptions.get(str)!; } else { const usercolor = getHexColorFromString(str); colorOptions.set(str, usercolor); return usercolor; } }; export const UserAvatar = ({ userId, username, className, }: { userId: UsersId; username?: string; className?: string; }) => { const userColor = getUserColor(userId); return ( {username && getInitials(username)} ); };