Organigramm: Einheiten nach Art farbig und mit Etikett
Some checks failed
CI / Lint, Typen, Tests, Build (push) Has been cancelled
CI / Migrationen auf leerer Datenbank (push) Has been cancelled
CI / Ausrollen (push) Has been cancelled

In der Struktursicht traegt jede Einheit die Farbe ihrer Art im Streifen
links, von dunkel nach hell: Gesellschaft, Vorstandsbereich, Bereich,
Abteilung, Team. Dazu die Art als Etikett am oberen Rand der Karte - die
Farbe hilft beim Herauszoomen, das Etikett beim Lesen und fuer alle, die
Farben nicht unterscheiden.

Geprueft: lint, tsc, 1032 Tests, Waechter.
This commit is contained in:
2026-11-03 10:12:04 +01:00
parent 67eeeafa6c
commit 57b3381e68
3 changed files with 33 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import { Building2, ChevronDown, Plus, Trash2, UserRound } from "lucide-react";
import Link from "next/link";
import { memo } from "react";
import { Avatar } from "@/components/ui/Avatar";
import type { OrgUnitType } from "@/lib/org-art";
import { NODE_DIMENSIONS } from "./graphLayout";
import type { ChartNode, ChartNodeKind } from "./types";
@@ -37,6 +38,26 @@ const KIND_ACCENT: Record<ChartNodeKind, string> = {
vacancy: "bg-accent-500",
};
// Einheiten tragen statt der Farbe ihrer Knotenart die Farbe ihrer Art, von
// dunkel nach hell absteigend, dazu die Art als Etikett am oberen Rand. Die
// Farbe trägt beim Herauszoomen, das Etikett beim Lesen — und für alle, die
// Farben nicht unterscheiden.
const ART_ACCENT: Record<OrgUnitType, string> = {
Gesellschaft: "bg-brand-700",
Vorstandsbereich: "bg-brand-500",
Bereich: "bg-info-text",
Abteilung: "bg-purple-text",
Team: "bg-ink-muted",
};
const ART_ETIKETT: Record<OrgUnitType, string> = {
Gesellschaft: "border-brand-700 bg-brand-700 text-white",
Vorstandsbereich: "border-brand-500 bg-brand-500 text-white",
Bereich: "border-info-text bg-info-bg text-info-text",
Abteilung: "border-purple-text bg-purple-bg text-purple-text",
Team: "border-border-strong bg-white text-ink-muted",
};
const KIND_SHELL: Record<ChartNodeKind, string> = {
person: "border-border bg-white",
role: "border-border bg-white",
@@ -48,7 +69,7 @@ const KIND_SHELL: Record<ChartNodeKind, string> = {
// required, not just tidy, to keep that smooth at a few hundred nodes.
export const OrgChartNode = memo(function OrgChartNode({ id, data }: NodeProps<OrgChartRFNode>) {
const { chartNode, expanded, hasChildren, childCount, onToggle, onAddUnit, onDeleteUnit, onSelectUnit } = data;
const { kind, label, sublabel, avatar, href, vacant, totalReports, absent, coveredBy, coveringFor, unitId } = chartNode;
const { kind, label, sublabel, avatar, href, vacant, totalReports, absent, coveredBy, coveringFor, unitId, unitType } = chartNode;
const isMatch = chartNode.matched ?? false;
const { width, height } = NODE_DIMENSIONS[kind];
@@ -157,7 +178,14 @@ export const OrgChartNode = memo(function OrgChartNode({ id, data }: NodeProps<O
)}
{/* Accent stripe, inset so it follows the card's rounded corner. */}
<span className={`absolute inset-y-1.5 left-0 w-1 rounded-r ${KIND_ACCENT[kind]}`} />
<span className={`absolute inset-y-1.5 left-0 w-1 rounded-r ${unitType ? ART_ACCENT[unitType] : KIND_ACCENT[kind]}`} />
{unitType && (
<span
className={`pointer-events-none absolute -top-2 left-3 rounded border px-1.5 text-[9px] font-bold uppercase leading-[14px] tracking-wide ${ART_ETIKETT[unitType]}`}
>
{unitType}
</span>
)}
{href ? (
<Link href={href} className="nodrag nopan flex min-w-0 flex-1 items-center gap-2.5 py-2 pl-3.5 pr-3">