// [275] Umbau-Farben bearbeiten: je Status Füllung und Linie als freie Farbe ODER Stift (der gemeinsame `PenColorField` // der App: Frei/Stift-Umschalter, Stift-Raster des aktiven Stiftsatzes), „gestrichelt“, Zurücksetzen je Status. Eine // Komponente für das Umbau-Panel (Abschnitt „Darstellung“, Etappen) und den Ressourcen-Tab „Umbau“ — reine Darstellung, // die Änderung geht als ganzes `RenovationStyles` an `onChange` (der Aufrufer macht daraus Ops). import { t } from "../i18n"; import type { TranslationKey } from "../i18n"; import type { Project, RenovationStatus, RenovationStyle, RenovationStyles } from "../model/types"; import { activePenSet } from "../model/penSets"; import { patchRenovationStyles, RENOVATION_STATUSES } from "../core"; import type { RenovationStyleSet } from "../core"; import { PenColorField } from "./PenColorField"; export interface RenovationStyleEditorProps { project: Project; /** Eigene Angaben (Projekt oder Etappe); `undefined` = keine. */ styles: RenovationStyles | undefined; /** Aufgelöste Farben, die gerade gelten (Kern), für die Anzeige. */ shown: RenovationStyleSet; onChange: (next: RenovationStyles | undefined, status: RenovationStatus) => void; statuses?: readonly RenovationStatus[]; /** „gestrichelt“ für diese Status anbieten (Vorgabe: nur Abbruch). */ dashedFor?: readonly RenovationStatus[]; disabled?: boolean; /** Präfix der `data-testid` (z. B. `reno-style` → `reno-style-new`). */ testId: string; onSaveColor?: (paletteId: string, hex: string) => void; } export function RenovationStyleEditor({ project, styles, shown, onChange, statuses = RENOVATION_STATUSES, dashedFor = ["demolish"], disabled, testId, onSaveColor }: RenovationStyleEditorProps) { const pens = project.pens ?? []; const activeStyles = activePenSet(project)?.pens; const patch = (s: RenovationStatus, p: Partial | null) => onChange(patchRenovationStyles(styles, s, p), s); return (
{statuses.map((s) => { const own = styles?.[s]; const st = shown[s]; return (
{t(`renovation.status.${s}` as TranslationKey)} patch(s, { fill })} onPenChange={(fillPen) => patch(s, fillPen ? { fillPen } : { fillPen: undefined, fill: st.fill })} /> patch(s, { line })} onPenChange={(linePen) => patch(s, linePen ? { linePen } : { linePen: undefined, ...(st.line ? { line: st.line } : {}) })} /> {dashedFor.includes(s) ? ( ) : ( )}
); })}
); }