Files
alpenwerk-hr/components/ui/Avatar.tsx
Andrei Laas 6a7106c95d Alpenwerk HR -- interne HR-Stammdatenverwaltung
Mitarbeiter:innen, Organisationsstruktur, Planstellen, Eintritt, Austritt,
Versetzung, Befoerderung, Karenz, On- und Offboarding, Berichte, Massenimport
und ein lueckenloser Nachweis jeder Aenderung.

Next.js 16 mit React 19 und TypeScript, PostgreSQL 17 ueber Kysely, Anmeldung
ueber Microsoft Entra ID. Die Fachlogik liegt in der Datenbank: rund dreissig
PL/pgSQL-Funktionen fuehren eine Aenderung, ihren Historieneintrag und ihren
Protokolleintrag in einer Transaktion aus. Die Zugriffsschranke ist Row Level
Security, nicht die Oberflaeche.

Betrieb auf Windows Server ohne Docker: ein fertiges Paket, ein Windows-Dienst,
der IIS als HTTPS-Vorschaltung und zwei geplante Aufgaben. Siehe
deploy/windows/README.md.
2026-10-13 20:11:18 +02:00

33 lines
1.1 KiB
TypeScript

import { avatarColorFor } from "@/lib/colors";
import { initials } from "@/lib/format";
type AvatarProps = {
firstName: string;
lastName: string;
color?: string | null;
size?: "sm" | "md" | "lg";
};
const SIZE_CLASSES: Record<NonNullable<AvatarProps["size"]>, string> = {
sm: "h-7 w-7 text-xs",
md: "h-9 w-9 text-sm",
lg: "h-14 w-14 text-lg",
};
export function Avatar({ firstName, lastName, color, size = "md" }: AvatarProps) {
const bg = color ?? avatarColorFor(`${firstName}${lastName}`);
return (
<span
// A white ring separates adjacent avatars in the org chart and lets a
// strongly coloured one sit on a tinted row without vibrating against
// it. aria-hidden because the name is always rendered next to it —
// otherwise a screen reader reads the initials and then the name again.
className={`inline-flex shrink-0 select-none items-center justify-center rounded-full font-bold leading-none text-white ring-2 ring-white ${SIZE_CLASSES[size]}`}
style={{ backgroundColor: bg }}
aria-hidden
>
{initials(firstName, lastName)}
</span>
);
}