63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import {
|
|
Bike,
|
|
Bird,
|
|
Camera,
|
|
Cat,
|
|
Dog,
|
|
Fish,
|
|
Flame,
|
|
Gamepad2,
|
|
Guitar,
|
|
Headphones,
|
|
Mountain,
|
|
Palette,
|
|
Rabbit,
|
|
Rocket,
|
|
Snail,
|
|
Squirrel,
|
|
Trophy,
|
|
Turtle,
|
|
UserRound,
|
|
Volleyball,
|
|
} from "lucide-react";
|
|
import { initials } from "@/lib/avatars";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
const ICONS = {
|
|
cat: Cat,
|
|
dog: Dog,
|
|
rabbit: Rabbit,
|
|
bird: Bird,
|
|
fish: Fish,
|
|
turtle: Turtle,
|
|
squirrel: Squirrel,
|
|
snail: Snail,
|
|
gamepad: Gamepad2,
|
|
headphones: Headphones,
|
|
guitar: Guitar,
|
|
volleyball: Volleyball,
|
|
bike: Bike,
|
|
camera: Camera,
|
|
palette: Palette,
|
|
rocket: Rocket,
|
|
mountain: Mountain,
|
|
trophy: Trophy,
|
|
flame: Flame,
|
|
};
|
|
|
|
/** Bild einer Person; „initials“ zeigt die Anfangsbuchstaben (ohne Namen: „Aa“ als Muster). */
|
|
export function AvatarIcon({ avatar, name, className }: { avatar: string | null; name?: string; className?: string }) {
|
|
if (avatar === "initials") {
|
|
return (
|
|
<svg aria-hidden viewBox="0 0 40 40" className={cn("size-full", className)}>
|
|
<circle cx="20" cy="20" r="18.5" fill="none" stroke="currentColor" strokeWidth="1.5" />
|
|
<text x="20" y="20" dy="0.36em" textAnchor="middle" fontSize={name && initials(name).length > 1 ? 15 : 18} fontWeight="600" fill="currentColor">
|
|
{name ? initials(name) || "?" : "Aa"}
|
|
</text>
|
|
</svg>
|
|
);
|
|
}
|
|
const Icon = (avatar && ICONS[avatar as keyof typeof ICONS]) || UserRound;
|
|
return <Icon aria-hidden className={cn("size-full", className)} strokeWidth={1.5} />;
|
|
}
|