Merge [275] Umbau-Farben: Farbe oder Stift, gedämpfte Vorgabe, eigene Farben je Etappe

This commit is contained in:
Claude committed 2026-11-17 20:22:23 +00:00
commit ff7d80432d
40 files changed
+955 -143

No files matched your search

+1 -1
View File
@@ -254,7 +254,7 @@ echo "Finished Rendering."
expect((await quiet(() => base(["--renovation", "umbauplan"]))).result).toBe(0);
expect(sceneXml()).not.toContain("Umbau-");
expect((await quiet(() => base(["--renovation", "umbauplan", "--renovation-colors"]))).result).toBe(0);
expect(sceneXml()).toContain("Umbau-ffd800");
expect(sceneXml()).toContain("Umbau-e8c35a");
const vb = (extra: string[]) => run([":varianten", "render", "--engine", "cycles", "--cycles", fakeCycles, "--out", join(dir, "var.png"), "--samples", "8", "--size", "8x4", "--no-context", ...extra]);
expect((await quiet(() => vb([]))).result).toBe(0);
const studie1 = sceneXml();
+1
View File
@@ -184,6 +184,7 @@ export type QueryName =
| "kennzahlen"
| "areaTable"
| "renovationFilters"
| "renovationStyles"
| "renovationPair"
| "renovationPairs"
| "designOptionInfo"
+3 -1
View File
@@ -125,11 +125,13 @@ export type { CostResult, CostRow, CostQuantities, CostEstimate, CostGroup, Cost
export { buildCostReport, costGroupLabel, costUnitLabel } from "../export/costReport";
// [271] Umbau: Status je Bauteil, Etappen, Umbaufilter (Regeln im Kern `renovation.rs`)
export {
BUILTIN_RENOVATION_FILTERS, RENOVATION_STATUSES, RENOVATION_COLLECTIONS, DEFAULT_RENOVATION_STYLES, renovationFilterList, renovationStatus, renovationPhases,
BUILTIN_RENOVATION_FILTERS, RENOVATION_STATUSES, RENOVATION_COLLECTIONS, renovationFilterList, renovationStatus, renovationPhases,
renovationForNew, setRenovationOps, renovatableIds, commonRenovation, setPhasesOps, newPhaseId,
renovationFilterShows, renovationStyleOf, idsByRenovationStatus, renovationCounts, phaseUsage,
resolvedRenovationStyles, patchRenovationStyles, setRenovationStylesOps, setPhaseStylesOps,
} from "../model/renovation";
export type { RenovationFilterEntry, RenovationCollection } from "../model/renovation";
export type { RenovationStyleView, RenovationStyleSet, ResolvedRenovationStyles } from "../model/renovation";
// [274] Sanierung je Schicht: Typ-Paar Bestand → Sanierungstyp
export {
wallBuildUp, buildUpKey, parseBuildUpKey, setBuildUpOps, commonBuildUp, renovateAllOfTypeOps, createRenovationTypeOps, setTypePairOps,
+1 -1
View File
@@ -91,7 +91,7 @@ describe("Exporte folgen der Ansicht", () => {
const plan = { ...base, renovation: "umbauplan" };
expect(cyclesSceneInfo(u, plan).xml).not.toContain("Umbau-");
const farbig = cyclesSceneInfo(u, { ...plan, renovationColors: true });
expect(farbig.xml).toContain("Umbau-ffd800");
expect(farbig.xml).toContain("Umbau-e8c35a");
expect(farbig.triangles).toBe(cyclesSceneInfo(u, plan).triangles);
const v = buildVariantenSampleProject();
+7
View File
@@ -4758,6 +4758,13 @@ export const de = {
"renovation.panel.phases.deleteMessageUnused": "Etappe „{name}“ löschen?",
"renovation.panel.phases.delete": "Löschen",
"renovation.panel.colors": "Umbau-Farben in den Ressourcen …",
"renovation.panel.styles.title": "Darstellung",
"renovation.panel.styles.hint": "Je Status Füllung und Linie als Farbe oder Stift: ein Stift nimmt die Farbe aus dem aktiven Stiftsatz (z. B. Plot S/W).",
"renovation.panel.styles.sia": "SIA-Vorgabe",
"renovation.panel.styles.siaHint": "Umbau-Farben auf die Vorgabe nach SIA 400 zurücksetzen (Bestand grau, Abbruch gelb gestrichelt, Neu rot)",
"renovation.panel.phases.styles": "Eigene Farben der Etappe",
"renovation.panel.phases.stylesHint": "Abbruch und Neu der Etappe „{name}“ in eigener Farbe; leer = Farben des Projekts.",
"renovation.panel.phases.stylesReset": "Farben des Projekts verwenden",
"renovation.buildUp": "Neuer Aufbau (Sanierung)",
"renovation.buildUp.none": "keiner",
"renovation.buildUp.type": "wie Typ: {name}",
+7
View File
@@ -4744,6 +4744,13 @@ export const en: Record<TranslationKey, string> = {
"renovation.panel.phases.deleteMessageUnused": "Delete phase “{name}”?",
"renovation.panel.phases.delete": "Delete",
"renovation.panel.colors": "Renovation colors in the resources …",
"renovation.panel.styles.title": "Appearance",
"renovation.panel.styles.hint": "Fill and line per status as a color or a pen: a pen takes its color from the active pen set (e.g. plot B/W).",
"renovation.panel.styles.sia": "SIA default",
"renovation.panel.styles.siaHint": "Reset renovation colors to the SIA 400 default (existing grey, demolition yellow dashed, new red)",
"renovation.panel.phases.styles": "Own colors of the phase",
"renovation.panel.phases.stylesHint": "Demolition and new elements of phase “{name}” in their own color; empty = project colors.",
"renovation.panel.phases.stylesReset": "Use project colors",
"renovation.buildUp": "New build-up (refurbishment)",
"renovation.buildUp.none": "none",
"renovation.buildUp.type": "as type: {name}",
+5 -5
View File
@@ -54,13 +54,13 @@ describe("[271] Umbau", () => {
const p = buildUmbauSampleProject();
expect(renovationFilterList(p).map((f) => f.id)).toEqual(["bestand", "abbruch", "neubau", "umbauplan", "endzustand"]);
// Ohne Filter keine Umbau-Farben; Umbauplan grau, gelb und rot.
expect(fills(p)).not.toContain("#e3001b");
expect(fills(p)).not.toContain("#c8524a");
const u = fills(p, "umbauplan");
for (const c of ["#a6a6a6", "#ffd800", "#e3001b"]) expect(u).toContain(c);
for (const c of ["#a6a6a6", "#e8c35a", "#c8524a"]) expect(u).toContain(c);
// Neubau: kein Gelb (Abbruch weg), Rot da.
const n = fills(p, "neubau");
expect(n).not.toContain("#ffd800");
expect(n).toContain("#e3001b");
expect(n).not.toContain("#e8c35a");
expect(n).toContain("#c8524a");
// Kennzahlen: der Anbau zählt nur im Endzustand.
const b = computeKennzahlen(p, "bestand");
const e = computeKennzahlen(p, "endzustand");
@@ -81,7 +81,7 @@ describe("[271] Umbau", () => {
// ── Panel „Umbau“ ──
it("Panel: Vorschau je Filter stimmt mit dem Grundriss des Kerns überein (Override = Farbe da, Hide/Show = keine)", () => {
const p = buildUmbauSampleProject();
const colour = { existing: "#a6a6a6", demolish: "#ffd800", new: "#e3001b" } as const;
const colour = { existing: "#a6a6a6", demolish: "#e8c35a", new: "#c8524a" } as const;
for (const f of renovationFilterList(p)) {
const shows = renovationFilterShows(p, f.id)!;
const got = fills(p, f.id);
+74 -12
View File
@@ -4,7 +4,7 @@
import type { CoreOp } from "../core/ops";
import { documentFor } from "../core/document";
import { addItems, patchItem, patchItems, setField } from "../core/opsBuild";
import type { LayerRenovation, Project, Renovation, RenovationPhase, RenovationShow, RenovationSide, RenovationStatus, Tree, TreeStatus, WallType } from "./types";
import type { LayerRenovation, Project, Renovation, RenovationPhase, RenovationShow, RenovationSide, RenovationStatus, RenovationStyle, RenovationStyles, Tree, TreeStatus, WallType } from "./types";
/** Eingebaute Umbaufilter (Ids; Namen über `t("renovation.filter.<id>")`). */
export const BUILTIN_RENOVATION_FILTERS = ["bestand", "abbruch", "neubau", "umbauplan", "endzustand"] as const;
@@ -26,12 +26,75 @@ export type RenovationCollection = (typeof RENOVATION_COLLECTIONS)[number];
const TREE_STATUS_OF: Record<RenovationStatus, TreeStatus> = { existing: "existing", demolish: "remove", new: "new" };
export const treeRenovationStatus = (t: Tree): RenovationStatus => (t.status === "remove" ? "demolish" : t.status === "new" ? "new" : "existing");
/** SIA-400-Vorgabe der Umbau-Farben (gleich wie `renovation::default_style` im Kern). */
export const DEFAULT_RENOVATION_STYLES: Record<RenovationStatus, { fill: string; line?: string; dashed: boolean }> = {
existing: { fill: "#a6a6a6", dashed: false },
demolish: { fill: "#ffd800", dashed: true },
new: { fill: "#e3001b", line: "#c00016", dashed: false },
};
/** Aufgelöste Umbau-Farbe eines Status (Stift schon in Farbe übersetzt). */
export interface RenovationStyleView {
fill: string;
line?: string;
dashed: boolean;
}
export type RenovationStyleSet = Record<RenovationStatus, RenovationStyleView>;
/** [275] Umbau-Farben, wie der Kern sie auflöst: SIA-Vorgabe, Projekt, Etappen mit eigenen Farben (Id → je Status). */
export interface ResolvedRenovationStyles {
defaults: RenovationStyleSet;
project: RenovationStyleSet;
phases: Record<string, RenovationStyleSet>;
}
type RawStyle = { fill: string; line: string | null; dashed: boolean };
const cleanSet = (x: Record<RenovationStatus, RawStyle>): RenovationStyleSet =>
Object.fromEntries(RENOVATION_STATUSES.map((s) => [s, { fill: x[s].fill, ...(x[s].line ? { line: x[s].line } : {}), dashed: x[s].dashed }])) as RenovationStyleSet;
/**
* [275] Umbau-Farben des Projekts (Kern-Abfrage `renovationStyles`, `renovation::style`/`phase_style`): eine Wahrheit
* für Plan und Muster der Oberfläche — Stifte (aktiver Stiftsatz) und Etappen-Farben sind schon aufgelöst.
*/
export function resolvedRenovationStyles(project: Project): ResolvedRenovationStyles {
const raw = documentFor(project).query<{ defaults: Record<RenovationStatus, RawStyle>; project: Record<RenovationStatus, RawStyle>; phases: Record<string, Record<RenovationStatus, RawStyle>> }>("renovationStyles");
return {
defaults: cleanSet(raw.defaults),
project: cleanSet(raw.project),
phases: Object.fromEntries(Object.entries(raw.phases ?? {}).map(([k, v]) => [k, cleanSet(v)])),
};
}
/**
* [275] Eine Umbau-Farbe ändern (`patch`; `null` = zurück auf die Vorgabe): fehlende Felder gelten als „wie Vorgabe“,
* Farbe und Stift schliessen sich aus (wer eine freie Farbe setzt, löst den Stift und umgekehrt). `undefined` = leer.
*/
export function patchRenovationStyles(styles: RenovationStyles | undefined, status: RenovationStatus, patch: Partial<RenovationStyle> | null): RenovationStyles | undefined {
const next: RenovationStyles = { ...(styles ?? {}) };
if (patch === null) delete next[status];
else {
const merged: RenovationStyle = { ...(next[status] ?? {}), ...patch };
if ("fill" in patch && patch.fill !== undefined) delete merged.fillPen;
if ("fillPen" in patch && patch.fillPen !== undefined) delete merged.fill;
if ("line" in patch && patch.line !== undefined) delete merged.linePen;
if ("linePen" in patch && patch.linePen !== undefined) delete merged.line;
for (const k of Object.keys(merged) as (keyof RenovationStyle)[]) if (merged[k] === undefined) delete merged[k];
if (Object.keys(merged).length) next[status] = merged;
else delete next[status];
}
return Object.keys(next).length ? next : undefined;
}
/** [275] Ops: Umbau-Farben des Projekts ersetzen (`undefined` = SIA-Vorgabe). */
export function setRenovationStylesOps(project: Project, styles: RenovationStyles | undefined): CoreOp[] {
const next = { ...(project.renovation ?? {}) };
if (styles) next.styles = styles;
else delete next.styles;
return [setField("renovation", Object.keys(next).length ? next : undefined)];
}
/** [275] Ops: eigene Umbau-Farben einer Etappe ersetzen (`undefined` = Farben des Projekts). */
export function setPhaseStylesOps(project: Project, phaseId: string, styles: RenovationStyles | undefined): CoreOp[] {
const phases = renovationPhases(project).map((ph) => {
if (ph.id !== phaseId) return ph;
const { styles: _drop, ...rest } = ph;
void _drop;
return styles ? { ...rest, styles } : rest;
});
return setPhasesOps(project, phases);
}
export interface RenovationFilterEntry {
id: string;
@@ -187,11 +250,10 @@ export function renovationFilterShows(project: Project, id: string): Record<Reno
return BUILTIN_FILTER_SHOWS[id] ?? null;
}
/** Umbau-Farbe eines Status (Projekt-Vorgabe über SIA-400-Vorgabe). */
export function renovationStyleOf(project: Project, status: RenovationStatus): { fill: string; line?: string; dashed: boolean } {
const d = DEFAULT_RENOVATION_STYLES[status];
const o = project.renovation?.styles?.[status];
return { fill: o?.fill ?? d.fill, line: o?.line ?? d.line, dashed: o?.dashed ?? d.dashed };
/** Umbau-Farbe eines Status (Etappe `phaseId` mit eigenen Farben, sonst Projekt, sonst SIA-Vorgabe; Kern löst auf). */
export function renovationStyleOf(project: Project, status: RenovationStatus, phaseId?: string | null): RenovationStyleView {
const r = resolvedRenovationStyles(project);
return (phaseId ? r.phases[phaseId]?.[status] : undefined) ?? r.project[status];
}
/** Möbel und Symbole (Objekte der Bibliothek, Blöcke): nehmen ohne Angabe als Bestand am Umbaufilter teil. */
+1 -1
View File
@@ -89,7 +89,7 @@ describe("[274] Sanierung je Schicht", () => {
expect(pr?.result.map((q) => q.kind)).toEqual(["new", "new", "newOverDemolish", "newOverDemolish", "kept"]);
expect(renovationPairs(p).renovated).toBe(1);
// Grundriss: Abbruch gelb, Umbauplan mit gelber gestrichelter Kontur über Rot.
const dashedYellow = (prims: ReturnType<typeof plan>) => prims.some((x) => x.kind === "line" && !!x.dash && x.color === "#ffd800");
const dashedYellow = (prims: ReturnType<typeof plan>) => prims.some((x) => x.kind === "line" && !!x.dash && x.color === "#e8c35a");
expect(dashedYellow(plan(p, "umbauplan"))).toBe(true);
expect(dashedYellow(plan(p, "endzustand"))).toBe(false);
// GF im Endzustand: die Südwand ist 10 cm dicker als ohne Sanierung (die Aussenkante rückt nach aussen).
+80
View File
@@ -0,0 +1,80 @@
// [275] Umbau-Farben: gedämpfte Vorgabe, Farbe ODER Stift (aktiver Stiftsatz), eigene Farben je Etappe — Auflösung im Kern
// (`renovationStyles`), Ops der Oberfläche, und dass der Grundriss genau die Farben der Muster zeigt.
import { describe, expect, it } from "vitest";
import { applyOps } from "../core/ops";
import { generatePlan } from "../plan/generatePlan";
import { buildUmbauSampleProject } from "./sampleProjectUmbau";
import { patchRenovationStyles, renovationStyleOf, resolvedRenovationStyles, setPhaseStylesOps, setRenovationStylesOps } from "./renovation";
import type { Project } from "./types";
const ALL = new Set(["20", "21", "30", "31", "40", "60"]);
function fills(p: Project, filter: string): string[] {
const q = { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === "eg" ? { ...l, renovationFilter: filter } : l)) };
return generatePlan(q, "eg", ALL).primitives.flatMap((x) => (x.kind === "polygon" ? [x.fill] : []));
}
describe("[275] Umbau-Farben", () => {
it("Vorgabe gedämpft: Ocker-Gelb, Ziegelrot, Grau", () => {
const r = resolvedRenovationStyles(buildUmbauSampleProject());
expect(r.defaults.demolish).toEqual({ fill: "#e8c35a", dashed: true });
expect(r.defaults.new).toEqual({ fill: "#c8524a", line: "#9e3a33", dashed: false });
expect(r.defaults.existing.fill).toBe("#a6a6a6");
});
it("Farbe und Stift schliessen sich aus; leer = Vorgabe", () => {
let s = patchRenovationStyles(undefined, "new", { fill: "#123456" });
expect(s).toEqual({ new: { fill: "#123456" } });
s = patchRenovationStyles(s, "new", { fillPen: "3" });
expect(s).toEqual({ new: { fillPen: "3" } });
s = patchRenovationStyles(s, "new", { line: "#000000" });
s = patchRenovationStyles(s, "new", { linePen: "4" });
expect(s).toEqual({ new: { fillPen: "3", linePen: "4" } });
s = patchRenovationStyles(s, "demolish", { dashed: false });
expect(patchRenovationStyles(patchRenovationStyles(s, "new", null), "demolish", null)).toBeUndefined();
});
it("Stift: Farbe aus dem aktiven Stiftsatz, ein S/W-Satz färbt den Umbauplan um", () => {
const base = buildUmbauSampleProject();
const withPens: Project = {
...base,
pens: [...(base.pens ?? []), { id: "u1", name: "Umbau Neu" }],
penSets: [
{ id: "farbe", name: "Farbe", pens: { u1: { color: "#3366cc", weight: 0.25 } } },
{ id: "sw", name: "S/W", pens: { u1: { color: "#999999", weight: 0.25 } } },
],
activePenSetId: "farbe",
};
const p = applyOps(withPens, setRenovationStylesOps(withPens, { new: { fillPen: "u1" } }));
expect(renovationStyleOf(p, "new").fill).toBe("#3366cc");
expect(fills(p, "umbauplan")).toContain("#3366cc");
const sw = { ...p, activePenSetId: "sw" };
expect(renovationStyleOf(sw, "new").fill).toBe("#999999");
expect(fills(sw, "umbauplan")).toContain("#999999");
expect(fills(sw, "umbauplan")).not.toContain("#3366cc");
// SIA-Vorgabe zurück.
const back = applyOps(p, setRenovationStylesOps(p, undefined));
expect(back.renovation?.styles).toBeUndefined();
expect(renovationStyleOf(back, "new").fill).toBe("#c8524a");
});
it("Etappe mit eigener Farbe: Neu der Etappe 2 im Beispiel in eigener Farbe, Projektfarbe bleibt", () => {
const p0 = buildUmbauSampleProject();
const e2 = p0.renovation!.phases![1];
// Das Beispiel zeigt Etappe 2 schon in eigener Farbe.
expect(e2.styles?.new).toBeTruthy();
const own = renovationStyleOf(p0, "new", e2.id).fill;
expect(own).not.toBe(renovationStyleOf(p0, "new").fill);
expect(fills(p0, "umbauplan")).toContain(own);
// Zurück auf die Projektfarben: nur die Etappe ändert sich (Name, Reihenfolge, Elemente bleiben).
const p1 = applyOps(p0, setPhaseStylesOps(p0, e2.id, undefined));
expect(p1.renovation!.phases![1]).toEqual({ id: e2.id, name: e2.name });
expect(resolvedRenovationStyles(p1).phases[e2.id]).toBeUndefined();
expect(fills(p1, "umbauplan")).not.toContain(own);
expect(p1.walls.map((w) => w.renovation)).toEqual(p0.walls.map((w) => w.renovation));
// Neue eigene Farbe für Abbruch der Etappe.
const p2 = applyOps(p1, setPhaseStylesOps(p1, e2.id, { demolish: { fill: "#7a5c99" } }));
expect(resolvedRenovationStyles(p2).phases[e2.id].demolish.fill).toBe("#7a5c99");
expect(resolvedRenovationStyles(p2).phases[e2.id].new.fill).toBe("#c8524a");
});
});
+3 -1
View File
@@ -126,7 +126,9 @@ export function buildUmbauSampleProject(): Project {
renovation: {
phases: [
{ id: "etappe-1", name: "Etappe 1" },
{ id: "etappe-2", name: "Etappe 2" },
// [275] Etappe 2 (Anbau) mit eigener Farbe: Neues gedämpft blau statt rot, damit die zwei Etappen im Umbauplan
// auseinanderzuhalten sind.
{ id: "etappe-2", name: "Etappe 2", styles: { new: { fill: "#5b84b1", line: "#3e6390" } } },
],
},
};
+20 -2
View File
@@ -3439,7 +3439,15 @@ export type RenovationFilter = {
};
/** [271] Eine Bau-Etappe (Reihenfolge = Reihenfolge der Liste). */
export type RenovationPhase = { id: string; name: string };
export type RenovationPhase = {
id: string;
name: string;
/**
* [275] Eigene Umbau-Farben der Etappe (Neu/Abbruch dieser Etappe, z. B. Neubau Etappe 2 blau); fehlende Felder
* ⇒ die Farben des Projekts (`RenovationSettings.styles`), dann die SIA-Vorgabe.
*/
styles?: RenovationStyles;
};
/** [271] Umbau-Einstellungen des Projekts. */
export type RenovationSettings = {
@@ -3466,8 +3474,18 @@ export type RenovationStatus = "existing" | "demolish" | "new";
/**
* [271] Umbau-Farbe eines Status: Füllung der Schnittflächen, Linienfarbe, gestrichelt. Fehlende Felder ⇒ SIA-Vorgabe.
* [275] Statt einer freien Farbe ein Stift (`ColorPen.id`): seine Farbe aus dem aktiven Stiftsatz geht der freien
* Farbe vor (ein S/W-Plot-Stiftsatz färbt so auch die Umbau-Farben um; Stift ohne Eintrag ⇒ freie Farbe/Vorgabe).
*/
export type RenovationStyle = { fill?: string; line?: string; dashed?: boolean };
export type RenovationStyle = {
fill?: string;
/** [275] Stift der Füllung. */
fillPen?: string;
line?: string;
/** [275] Stift der Linien. */
linePen?: string;
dashed?: boolean;
};
/** [271] Umbau-Farben je Status (fehlt ⇒ SIA-400-Vorgabe, `renovation::default_style`). */
export type RenovationStyles = { existing?: RenovationStyle; demolish?: RenovationStyle; new?: RenovationStyle };
+89 -18
View File
@@ -1,7 +1,8 @@
// Dock-Panel „Umbau“ ([271], Wunsch Maintainer 17.11., wie Archicads Palette Umbau): Zeichen-Status neuer Bauteile,
// Umbaufilter der aktiven Ansicht (mit Vorschau je Status), Status der Auswahl samt „nach Status wählen“ und die
// Etappen. Zustand und Aktionen teilt es mit dem Popover der Statusleiste (`state/renovationHook.ts`); Änderungen
// gehen als Ops über `applyChange` (ein Undo-Schritt je Aktion).
// gehen als Ops über `applyChange` (ein Undo-Schritt je Aktion). [275] Abschnitt „Darstellung“: Umbau-Farben je Status
// als Farbe oder Stift, „SIA-Vorgabe“; je Etappe eigene Farben (Muster in der Etappenliste).
//
// Bezeichner englisch, UI-Text/Kommentare deutsch (CONVENTIONS.md).
@@ -16,20 +17,23 @@ import {
phaseUsage,
renovationCounts,
renovationFilterShows,
renovationStyleOf,
resolvedRenovationStyles,
RENOVATION_STATUSES,
setPhasesOps,
setPhaseStylesOps,
setRenovationStylesOps,
} from "../core";
import type { Project, RenovationShow, RenovationStatus } from "../model/types";
import type { RenovationStyleView } from "../core";
import type { RenovationPhase, RenovationShow, RenovationStatus } from "../model/types";
import { ConfirmDialog } from "../ui/ConfirmDialog";
import { RenovationStyleEditor } from "../ui/RenovationStyleEditor";
import { usePanelHostAction } from "./host";
import { RenovationSanierung } from "./RenovationSanierung";
const MIXED = "__mixed";
/** Farbfeld eines Status (SIA-Farbmuster: Füllung, Linie, gestrichelt wie im Plan). */
function Swatch({ project, status, show }: { project: Project; status: RenovationStatus; show?: RenovationShow }) {
const st = renovationStyleOf(project, status);
/** Farbfeld eines Status (Umbau-Farbe: Füllung, Linie, gestrichelt wie im Plan). */
function Swatch({ st, show }: { st: RenovationStyleView; show?: RenovationShow }) {
const hidden = show === "hide";
const plain = show === "show";
return (
@@ -45,10 +49,10 @@ function Swatch({ project, status, show }: { project: Project; status: Renovatio
);
}
function ShowChip({ project, status, show }: { project: Project; status: RenovationStatus; show: RenovationShow }) {
function ShowChip({ st, status, show }: { st: RenovationStyleView; status: RenovationStatus; show: RenovationShow }) {
return (
<span className="reno-chip" data-testid={`reno-chip-${status}`} data-show={show}>
<Swatch project={project} status={status} show={show} />
<Swatch st={st} show={show} />
<span className="reno-chip-text">
<span className="reno-chip-status">{t(`renovation.status.${status}` as TranslationKey)}</span>
<span className="reno-chip-show">{t(`renovation.show.${show}` as TranslationKey)}</span>
@@ -63,7 +67,12 @@ export function RenovationPanel() {
const sel = useRenovationSelection();
const applyChange = useStore((s) => s.applyChange);
const openResources = usePanelHostAction("onOpenResources");
const saveColor = usePanelHostAction("onAddColorToCustomPalette");
const [confirmId, setConfirmId] = useState<string | null>(null);
const [stylePhase, setStylePhase] = useState<string | null>(null);
const rs = resolvedRenovationStyles(project);
const sw = rs.project;
const ownStyles = project.renovation?.styles;
const counts = renovationCounts(project, sel.floorId);
const shows = filter ? renovationFilterShows(project, filter) : null;
const filterIds = ["", ...BUILTIN_RENOVATION_FILTERS, ...own.map((f) => f.id)];
@@ -71,7 +80,7 @@ export function RenovationPanel() {
const statusValue = sel.common.status === "mixed" || sel.common.status === null ? null : sel.common.status;
const phaseValue = sel.common.phase === "mixed" ? MIXED : (sel.common.phase ?? "");
const setPhases = (next: { id: string; name: string }[], key?: string) => applyChange((p) => setPhasesOps(p, next), key);
const setPhases = (next: RenovationPhase[], key?: string) => applyChange((p) => setPhasesOps(p, next), key);
const move = (i: number, d: number) => {
const j = i + d;
if (j < 0 || j >= phases.length) return;
@@ -98,7 +107,7 @@ export function RenovationPanel() {
data-testid={`reno-draw-${s}`}
onClick={() => setDraw(s, draw.phase)}
>
<Swatch project={project} status={s} />
<Swatch st={sw[s]} />
<span>{t(`renovation.status.${s}` as TranslationKey)}</span>
</button>
))}
@@ -139,7 +148,7 @@ export function RenovationPanel() {
>
<span className="reno-filter-name">{id ? renovationFilterLabel(id, own) : t("renovation.filter.none")}</span>
<span className="reno-filter-sw">
{fs && RENOVATION_STATUSES.map((s) => <Swatch key={s} project={project} status={s} show={fs[s]} />)}
{fs && RENOVATION_STATUSES.map((s) => <Swatch key={s} st={sw[s]} show={fs[s]} />)}
</span>
</button>
</li>
@@ -167,12 +176,38 @@ export function RenovationPanel() {
{shows && (
<div className="reno-preview" aria-label={t("renovation.panel.filter.preview")} data-testid="reno-preview">
{RENOVATION_STATUSES.map((s) => (
<ShowChip key={s} project={project} status={s} show={shows[s]} />
<ShowChip key={s} st={sw[s]} status={s} show={shows[s]} />
))}
</div>
)}
</div>
{/* [275] Darstellung: Umbau-Farben je Status (Farbe oder Stift) */}
<div className="reno-block" data-testid="reno-styles">
<div className="reno-head">{t("renovation.panel.styles.title")}</div>
<RenovationStyleEditor
project={project}
styles={ownStyles}
shown={sw}
testId="reno-style"
onSaveColor={saveColor}
onChange={(next, s) => applyChange((p) => setRenovationStylesOps(p, next), `reno-style-${s}`)}
/>
<div className="reno-style-actions">
<button
type="button"
className="reno-link-btn"
disabled={!ownStyles}
data-testid="reno-style-sia"
title={t("renovation.panel.styles.siaHint")}
onClick={() => applyChange((p) => setRenovationStylesOps(p, undefined))}
>
{t("renovation.panel.styles.sia")}
</button>
</div>
<div className="reno-hint">{t("renovation.panel.styles.hint")}</div>
</div>
{/* Auswahl */}
<div className="reno-block">
<div className="reno-head">{t("renovation.panel.selection.title")}</div>
@@ -183,7 +218,7 @@ export function RenovationPanel() {
) : (
<>
<div className="reno-sel-state" data-testid="reno-sel-state" data-status={statusValue ?? "mixed"}>
{statusValue ? <Swatch project={project} status={statusValue} /> : <span className="reno-swatch is-mixed" aria-hidden="true" />}
{statusValue ? <Swatch st={sw[statusValue]} /> : <span className="reno-swatch is-mixed" aria-hidden="true" />}
<span>{statusValue ? t(`renovation.status.${statusValue}` as TranslationKey) : t("renovation.mixed")}</span>
<span className="reno-sel-count">{t("renovation.panel.selection.count", { n: String(sel.ids.length) })}</span>
</div>
@@ -196,7 +231,7 @@ export function RenovationPanel() {
data-testid={`reno-set-${s}`}
onClick={() => sel.setStatus(s)}
>
<Swatch project={project} status={s} />
<Swatch st={sw[s]} />
<span>{t("renovation.panel.set", { status: t(`renovation.status.${s}` as TranslationKey) })}</span>
</button>
))}
@@ -232,7 +267,7 @@ export function RenovationPanel() {
data-testid={`reno-select-${s}`}
onClick={() => sel.selectByStatus(s)}
>
<Swatch project={project} status={s} />
<Swatch st={sw[s]} />
{t("renovation.panel.selectAll", { status: t(`renovation.status.${s}` as TranslationKey), n: String(counts[s]) })}
</button>
))}
@@ -246,8 +281,25 @@ export function RenovationPanel() {
<div className="reno-block">
<div className="reno-head">{t("renovation.phases.title")}</div>
{phases.length === 0 && <div className="reno-hint">{t("renovation.phases.empty")}</div>}
{phases.map((ph, i) => (
<div className="reno-phase-row" key={ph.id} data-testid="reno-phase-row">
{phases.map((ph, i) => {
const pst = rs.phases[ph.id] ?? sw;
const own = !!rs.phases[ph.id];
const open = stylePhase === ph.id;
return (
<div className="reno-phase-item" key={ph.id}>
<div className="reno-phase-row" data-testid="reno-phase-row">
<button
type="button"
className={`reno-phase-sw${own ? " is-own" : ""}${open ? " active" : ""}`}
aria-expanded={open}
title={t("renovation.panel.phases.styles")}
aria-label={t("renovation.panel.phases.styles")}
data-testid="reno-phase-style"
onClick={() => setStylePhase(open ? null : ph.id)}
>
<Swatch st={pst.demolish} />
<Swatch st={pst.new} />
</button>
<input
type="text"
value={ph.name}
@@ -265,7 +317,26 @@ export function RenovationPanel() {
✕
</button>
</div>
))}
{open && (
<div className="reno-phase-styles" data-testid="reno-phase-styles">
<div className="reno-hint">{t("renovation.panel.phases.stylesHint", { name: ph.name })}</div>
<RenovationStyleEditor
project={project}
styles={ph.styles}
shown={pst}
statuses={["demolish", "new"]}
testId="reno-phase-style"
onSaveColor={saveColor}
onChange={(next, s) => applyChange((p) => setPhaseStylesOps(p, ph.id, next), `reno-phase-style-${ph.id}-${s}`)}
/>
<button type="button" className="reno-link-btn" disabled={!ph.styles} data-testid="reno-phase-style-reset" onClick={() => applyChange((p) => setPhaseStylesOps(p, ph.id, undefined))}>
{t("renovation.panel.phases.stylesReset")}
</button>
</div>
)}
</div>
);
})}
<button
type="button"
className="reno-add-btn"
+15 -2
View File
@@ -14,8 +14,9 @@ import {
idsByRenovationStatus,
patchItem,
setRenovationOps,
resolvedRenovationStyles,
} from "../core";
import type { RenovationStatus } from "../model/types";
import type { RenovationPhase, RenovationStatus } from "../model/types";
/** Anzeigename eines Filters (eingebaut übersetzt, eigene mit ihrem Namen). */
export function renovationFilterLabel(id: string, own: readonly { id: string; name: string }[]): string {
@@ -28,7 +29,7 @@ export function selectionRenovationIds(sel: Selection): string[] {
return [...sel.walls, ...sel.openings, ...sel.ceilings, ...sel.roofs, ...sel.stairs, ...sel.columns, ...sel.solids, ...sel.rooms, ...sel.drawings, ...sel.trees];
}
const NO_PHASES: readonly { id: string; name: string }[] = [];
const NO_PHASES: readonly RenovationPhase[] = [];
const NO_FILTERS: readonly { id: string; name: string }[] = [];
/**
@@ -83,3 +84,15 @@ export function useRenovationSelection() {
};
return { ids, common, floorId, setStatus, setPhase, selectByStatus };
}
/**
* [275] Umbau-Farben des Projekts (aufgelöst im Kern, Stifte inklusive) für Muster ausserhalb des Panels (Statusleiste).
* Hört nur auf Umbau-Einstellungen und Stiftsätze, nicht auf jede Op.
*/
export function useRenovationSwatches() {
const reno = useStore((s) => s.project.renovation);
const penSets = useStore((s) => s.project.penSets);
const active = useStore((s) => s.project.activePenSetId);
// eslint-disable-next-line react-hooks/exhaustive-deps
return useMemo(() => resolvedRenovationStyles(getState().project).project, [reno, penSets, active]);
}
+2 -8
View File
@@ -18,7 +18,7 @@ import type { useProjectActions } from "./useProjectActions";
import type { useTopBarState } from "./useTopBarState";
import { useViewTemplateHandlers } from "./useViewTemplateHandlers";
import { modelViewHandlers } from "./useModelViewHandlers";
import { setField, setPhasesOps, addDesignOptionSetOps, renameDesignOptionSetOps, addDesignOptionOps, renameDesignOptionOps, setPrimaryOptionOps, acceptDesignOptionOps, deleteDesignOptionOps } from "../core";
import { setPhasesOps, setRenovationStylesOps, addDesignOptionSetOps, renameDesignOptionSetOps, addDesignOptionOps, renameDesignOptionOps, setPrimaryOptionOps, acceptDesignOptionOps, deleteDesignOptionOps } from "../core";
type TopBar = ReturnType<typeof useTopBarState>;
type Dialogs = ReturnType<typeof useDialogState>;
@@ -138,13 +138,7 @@ export function useResourceHandlers(opts: {
...modelViewHandlers(applyChange, () => detail),
// [271] Umbau: Etappen und Farben (Ressourcen-Tab „Umbau“).
onSetRenovationPhases: (phases) => applyChange((p) => setPhasesOps(p, phases)),
onSetRenovationStyles: (styles) =>
applyChange((p) => {
const next = { ...(p.renovation ?? {}) };
if (styles) next.styles = styles;
else delete next.styles;
return [setField("renovation", Object.keys(next).length ? next : undefined)];
}),
onSetRenovationStyles: (styles) => applyChange((p) => setRenovationStylesOps(p, styles)),
// [272] Varianten (Ressourcen-Tab „Varianten“): Sätze/Varianten, Hauptvariante, Übernehmen, Löschen (je ein Undo-Schritt).
onAddDesignOptionSet: (name) => applyChange((p) => addDesignOptionSetOps(p, name).ops),
onRenameDesignOptionSet: (setId, name) => applyChange((p) => renameDesignOptionSetOps(p, setId, name), `dopt-set-${setId}`),
+95 -7
View File
@@ -10,6 +10,11 @@
:root {
color-scheme: light;
/* [275] Vorgabe der Umbau-Farben (Kern `renovation::default_style`); Muster mit Projektfarben setzen sie inline. */
--reno-existing: #a6a6a6;
--reno-demolish: #e8c35a;
--reno-new: #c8524a;
--bg: #e0dbd4;
--panel: #e0dbd4;
--panel-2: #d4cfc8;
@@ -1311,13 +1316,13 @@ body {
vertical-align: baseline;
}
.sb-renovation-existing {
background: #a6a6a6;
background: var(--reno-existing);
}
.sb-renovation-demolish {
background: #ffd800;
background: var(--reno-demolish);
}
.sb-renovation-new {
background: #e3001b;
background: var(--reno-new);
}
.sb-toggle.sb-renovation-on {
font-weight: 600;
@@ -9709,7 +9714,7 @@ body {
opacity: 0.6;
}
.reno-swatch.is-mixed {
background: repeating-linear-gradient(45deg, #a6a6a6 0 3px, #ffd800 3px 6px, #e3001b 6px 9px);
background: repeating-linear-gradient(45deg, var(--reno-existing) 0 3px, var(--reno-demolish) 3px 6px, var(--reno-new) 6px 9px);
}
.reno-status-row {
display: flex;
@@ -10363,13 +10368,13 @@ body {
min-width: 0;
}
.reno-fate.is-demolish {
box-shadow: inset 3px 0 0 #ffd800;
box-shadow: inset 3px 0 0 var(--reno-demolish);
}
.reno-fate.is-new {
box-shadow: inset 3px 0 0 #e3001b;
box-shadow: inset 3px 0 0 var(--reno-new);
}
.reno-fate.is-kept {
box-shadow: inset 3px 0 0 #a6a6a6;
box-shadow: inset 3px 0 0 var(--reno-existing);
}
.reno-create {
display: flex;
@@ -10380,3 +10385,86 @@ body {
min-width: 0;
flex: 1 1 auto;
}
/* ── [275] Umbau-Farben bearbeiten (Panel „Umbau“ › Darstellung, Etappen; Ressourcen-Tab „Umbau“) ───────────────── */
.reno-style-grid {
display: flex;
flex-direction: column;
gap: 4px;
}
.reno-style-row {
display: grid;
grid-template-columns: minmax(44px, 1fr) 44px 44px 84px 24px;
align-items: center;
gap: 6px;
}
.reno-style-label {
font-weight: 600;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.reno-style-field {
display: inline-flex;
align-items: center;
gap: 4px;
}
.reno-style-head .reno-style-cap {
justify-self: start;
}
.reno-style-cap {
font-size: 10px;
color: var(--muted);
}
.reno-style-dashed {
display: inline-flex;
align-items: center;
gap: 3px;
font-size: 11px;
color: var(--ink-2);
white-space: nowrap;
}
.reno-style-actions {
display: flex;
justify-content: flex-start;
}
.reno-phase-item {
display: flex;
flex-direction: column;
gap: 4px;
}
.reno-phase-sw {
flex: 0 0 auto;
display: inline-flex;
gap: 2px;
padding: 3px;
background: transparent;
border: 1px solid var(--border);
border-radius: 6px;
cursor: pointer;
}
.reno-phase-sw .reno-swatch {
width: 10px;
height: 14px;
}
.reno-phase-sw.is-own {
border-color: var(--ink-2);
}
.reno-phase-sw.active,
.reno-phase-sw:hover {
border-color: var(--active);
}
.reno-phase-styles {
display: flex;
flex-direction: column;
gap: 4px;
margin: 0 0 4px 22px;
padding: 6px 8px;
background: var(--input);
border: 1px solid var(--border);
border-radius: 8px;
}
.reno-phase-styles .reno-link-btn {
align-self: flex-start;
}
+3 -2
View File
@@ -6,7 +6,7 @@
import { useEffect, useRef, useState } from "react";
import { t } from "../i18n";
import type { TranslationKey } from "../i18n";
import { renovationFilterLabel, useRenovationControls } from "../state/renovationHook";
import { renovationFilterLabel, useRenovationControls, useRenovationSwatches } from "../state/renovationHook";
import { BUILTIN_RENOVATION_FILTERS, RENOVATION_STATUSES } from "../core";
import type { RenovationStatus } from "../model/types";
@@ -14,6 +14,7 @@ export { renovationFilterLabel };
export function RenovationControl() {
const { draw, setDraw, phases, own, filter, filterPhase, levelEditable, setLevel } = useRenovationControls();
const sw = useRenovationSwatches();
const [open, setOpen] = useState(false);
const wrapRef = useRef<HTMLSpanElement | null>(null);
useEffect(() => {
@@ -42,7 +43,7 @@ export function RenovationControl() {
title={t("renovation.status.hint", { status: statusLabel, filter: filterLabel })}
onClick={() => setOpen((v) => !v)}
>
<span className={`sb-renovation-dot sb-renovation-${draw.status}`} aria-hidden="true" />
<span className={`sb-renovation-dot sb-renovation-${draw.status}`} style={{ background: sw[draw.status].fill }} aria-hidden="true" />
{t("renovation.short", { status: statusLabel })}
</button>
{open && (
+1 -1
View File
@@ -33,7 +33,7 @@ export function RenovationStrip({ pair, width = 150 }: { pair: RenovationPair; w
const sum = (v: RenovationStripPiece[]) => v.reduce((a, q) => a + q.thickness, 0);
const max = Math.max(sum(pair.oldStrip), sum(pair.newStrip), sum(pair.result), 1e-6);
const scale = width / max;
const demolishFill = pair.result.find((q) => q.kind === "demolish")?.fill ?? pair.oldStrip.find((q) => q.kind === "demolish")?.fill ?? "#ffd800";
const demolishFill = pair.result.find((q) => q.kind === "demolish")?.fill ?? pair.oldStrip.find((q) => q.kind === "demolish")?.fill ?? "var(--reno-demolish)";
const row = (label: string, pieces: RenovationStripPiece[], id: string) => (
<div className="reno-strip-row" data-testid={`reno-strip-${id}`}>
<span className="reno-strip-label">{label}</span>
+101
View File
@@ -0,0 +1,101 @@
// [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<RenovationStyle> | null) => onChange(patchRenovationStyles(styles, s, p), s);
return (
<div className="reno-style-grid">
<div className="reno-style-row reno-style-head" aria-hidden="true">
<span />
<span className="reno-style-cap">{t("renovation.styles.fill")}</span>
<span className="reno-style-cap">{t("renovation.styles.line")}</span>
<span />
<span />
</div>
{statuses.map((s) => {
const own = styles?.[s];
const st = shown[s];
return (
<div className="reno-style-row" key={s} data-testid={`${testId}-${s}`} data-fill={st.fill} data-line={st.line ?? ""} data-dashed={String(st.dashed)}>
<span className="reno-style-label">{t(`renovation.status.${s}` as TranslationKey)}</span>
<span className="reno-style-field" title={t("renovation.styles.fill")} data-testid={`${testId}-${s}-fill`}>
<PenColorField
color={st.fill}
penId={own?.fillPen}
pens={pens}
activeStyles={activeStyles}
customPalettes={project.customPalettes}
builtinBanks={project.builtinPaletteBanks}
onSaveColor={onSaveColor}
disabled={disabled}
onColorChange={(fill) => patch(s, { fill })}
onPenChange={(fillPen) => patch(s, fillPen ? { fillPen } : { fillPen: undefined, fill: st.fill })}
/>
</span>
<span className="reno-style-field" title={t("renovation.styles.line")} data-testid={`${testId}-${s}-line`}>
<PenColorField
color={st.line ?? "#000000"}
penId={own?.linePen}
pens={pens}
activeStyles={activeStyles}
customPalettes={project.customPalettes}
builtinBanks={project.builtinPaletteBanks}
onSaveColor={onSaveColor}
disabled={disabled}
onColorChange={(line) => patch(s, { line })}
onPenChange={(linePen) => patch(s, linePen ? { linePen } : { linePen: undefined, ...(st.line ? { line: st.line } : {}) })}
/>
</span>
{dashedFor.includes(s) ? (
<label className="reno-style-dashed">
<input type="checkbox" checked={st.dashed} disabled={disabled} data-testid={`${testId}-${s}-dashed`} onChange={(e) => patch(s, { dashed: e.target.checked })} />
{t("renovation.styles.dashed")}
</label>
) : (
<span />
)}
<button
type="button"
className="reno-icon-btn"
disabled={disabled || !own}
title={t("renovation.styles.reset")}
aria-label={t("renovation.styles.reset")}
data-testid={`${testId}-${s}-reset`}
onClick={() => patch(s, null)}
>
↺
</button>
</div>
);
})}
</div>
);
}
+15 -36
View File
@@ -1,11 +1,12 @@
// [271] Ressourcen-Tab „Umbau“: Etappen (Name, Reihenfolge, hinzufügen/entfernen) und Umbau-Farben je Status
// (Füllung, Linie, gestrichelt; Vorgabe SIA 400: Bestand grau, Abbruch gelb gestrichelt, Neu rot).
// Reine Darstellung über Handler (wie die anderen Tabs, auch im macOS-Nebenfenster).
// Reine Darstellung über Handler (wie die anderen Tabs, auch im macOS-Nebenfenster). [275] Farben als Farbe oder Stift
// über den gemeinsamen Editor (`ui/RenovationStyleEditor.tsx`, wie im Umbau-Panel).
import { t } from "../../i18n";
import type { TranslationKey } from "../../i18n";
import type { Project, RenovationPhase, RenovationStatus, RenovationStyle, RenovationStyles } from "../../model/types";
import { DEFAULT_RENOVATION_STYLES, newPhaseId, RENOVATION_STATUSES, renovationPhases } from "../../core";
import type { Project, RenovationPhase, RenovationStyles } from "../../model/types";
import { newPhaseId, renovationPhases, resolvedRenovationStyles } from "../../core";
import { RenovationStyleEditor } from "../RenovationStyleEditor";
export interface RenovationHandlers {
/** Etappen-Liste ersetzen (Elemente einer entfernten Etappe verlieren sie). */
@@ -16,7 +17,7 @@ export interface RenovationHandlers {
export function RenovationTab({ project, handlers }: { project: Project; handlers: RenovationHandlers }) {
const phases = renovationPhases(project);
const styles = project.renovation?.styles ?? {};
const styles = project.renovation?.styles;
const setPhases = handlers.onSetRenovationPhases;
const setStyles = handlers.onSetRenovationStyles;
const move = (i: number, d: number) => {
@@ -26,13 +27,6 @@ export function RenovationTab({ project, handlers }: { project: Project; handler
[next[i], next[j]] = [next[j], next[i]];
setPhases(next);
};
const patchStyle = (s: RenovationStatus, patch: Partial<RenovationStyle> | null) => {
if (!setStyles) return;
const next: RenovationStyles = { ...styles };
if (patch === null) delete next[s];
else next[s] = { ...(styles[s] ?? {}), ...patch };
setStyles(Object.keys(next).length ? next : undefined);
};
return (
<div className="rm-renovation" data-testid="rm-renovation">
<h4 className="rm-subhead">{t("renovation.phases.title")}</h4>
@@ -70,30 +64,15 @@ export function RenovationTab({ project, handlers }: { project: Project; handler
<h4 className="rm-subhead">{t("renovation.styles.title")}</h4>
<p className="rm-hint">{t("renovation.styles.hint")}</p>
{RENOVATION_STATUSES.map((s) => {
const d = DEFAULT_RENOVATION_STYLES[s];
const own = styles[s] ?? {};
return (
<div className="rm-row" key={s} data-testid={`rm-renovation-style-${s}`}>
<span className="rm-label">{t(`renovation.status.${s}` as TranslationKey)}</span>
<label className="rm-inline">
{t("renovation.styles.fill")}
<input type="color" value={own.fill ?? d.fill} disabled={!setStyles} onChange={(e) => patchStyle(s, { fill: e.target.value })} />
</label>
<label className="rm-inline">
{t("renovation.styles.line")}
<input type="color" value={own.line ?? d.line ?? "#000000"} disabled={!setStyles} onChange={(e) => patchStyle(s, { line: e.target.value })} />
</label>
<label className="rm-inline">
<input type="checkbox" checked={own.dashed ?? d.dashed} disabled={!setStyles} onChange={(e) => patchStyle(s, { dashed: e.target.checked })} />
{t("renovation.styles.dashed")}
</label>
<button type="button" className="rm-icon-btn" disabled={!setStyles || !styles[s]} title={t("renovation.styles.reset")} aria-label={t("renovation.styles.reset")} onClick={() => patchStyle(s, null)}>
↺
</button>
</div>
);
})}
<RenovationStyleEditor
project={project}
styles={styles}
shown={resolvedRenovationStyles(project).project}
testId="rm-renovation-style"
dashedFor={["existing", "demolish", "new"]}
disabled={!setStyles}
onChange={(next) => setStyles?.(next)}
/>
</div>
);
}