Wunsch Maintainer 17.11.: Umbau-Farben nicht mehr hart, Farbe oder Stift wählbar, weniger leuchtendes Gelb und Rot. Vorgabe (renovation::default_style, eine Stelle für Plan, Schnitt, Ansicht, Axo, 3D, Cycles-Umbaufarben, Panel): Abbruch #e8c35a statt #ffd800, Neu #c8524a mit Linie #9e3a33 statt #e3001b/#c00016, Bestand #a6a6a6 unverändert. Begründung im Bild (doc/review-275/01, 01b, 02): Ocker bleibt auf weissem Papier klar gelb und neben dem Grau unterscheidbar, hat aber mehr Kontrast als das Signalgelb (Leuchtdichte ~0.58 statt ~0.70); das Ziegelrot ist ruhig, die Wand-Füllung deutlich gegen den grauen Bestand. Richtwerte unverändert übernommen. Eine eigene Abbruch-Linie (dunkles Ocker #ad8a2c) wurde ausprobiert: Möbel und Baum „zu fällen“ werden kräftiger, aber die Wandkontur wird ocker statt schwarz gestrichelt und verschwimmt mit der Füllung — darum Linie weiter „wie ohne Filter“ (dünnes Abbruch-Strichwerk bleibt blass, offen in TODO). Modell (Rust, gen:types): RenovationStyle.fillPen/linePen (ColorPen-Id; Farbe aus dem aktiven Stiftsatz beim Lesen, nicht eingebacken: ein S/W-Stiftsatz färbt den Umbauplan um; Stift ohne Eintrag ⇒ freie Farbe/Vorgabe), RenovationPhase.styles (eigene Farben der Etappe über der Projektfarbe). Kern: renovation::style/phase_style/apply_own, View.phase_styles; View::treat nimmt die Etappen-Farbe, solange das Element seinen eigenen Status zeigt (im Stand einer späteren Etappe ist es Bestand), Ersatzstücke nach der Etappe ihrer Öffnung, Sanierung je Schicht über treat; colors() (Tusche behält Farben) und key() mit Etappen-Farben. Abfrage renovationStyles (Vorgabe, Projekt, Etappen aufgelöst) — TS rechnet keine Farben mehr (DEFAULT_RENOVATION_STYLES entfernt, renovationStyleOf fragt den Kern). project_refs prüft die Stifte. Oberfläche: gemeinsamer Editor ui/RenovationStyleEditor.tsx mit dem PenColorField der App (Frei/Stift), gestrichelt, Zurücksetzen je Status — im Umbau-Panel (Abschnitt „Darstellung“, Knopf „SIA-Vorgabe“; je Etappe ein Farbmuster-Knopf mit eigenem Editor und „Farben des Projekts verwenden“) und im Ressourcen-Tab „Umbau“ (ersetzt die input type=color). Ops setRenovationStylesOps/setPhaseStylesOps/patchRenovationStyles (Farbe und Stift schliessen sich aus). Statusleisten-Punkt in der Projektfarbe (useRenovationSwatches, hört nur auf Umbau/Stiftsätze). CSS-Muster über --reno-*. Beispiel :umbau: Etappe 2 (Anbau) Neu gedämpft blau #5b84b1. Geprüft: Kern cargo test --release (1913 + robustness 14) und --features web robustness_web (3) grün, neu renovation_style_tests (6); WASM build:core --no-opt; tsc; vitest gesamt 3640 grün (neu model/renovationStyles.test.ts), Goldens ohne Änderung (kein Golden mit Umbau-Farben); e2e renovation271, renovationPanel271, renovation274, renderCount (43 Renders je Wand-Änderung, unverändert) und neu renovationStyles275 grün (Port 5196). Angesehen: CLI-SVG --hatch Grundriss EG 1:50 und Schnitt C vorher/nachher, Etappe 2 blau, Panel hell/dunkel im Browser-Build (Chromium/Linux). Nicht geprüft: Tauri/Mac, 3D-Fenster (render3d) und Cycles-Bild mit den neuen Farben (nur über Tests), Ressourcen-Tab nur per tsc (nicht angesehen).
125 lines
5.5 KiB
TypeScript
125 lines
5.5 KiB
TypeScript
// [271] Umbau in der Statusleiste: zeigt den aktuellen Zeichen-Status (neue Bauteile tragen ihn) und den Umbaufilter der
|
|
// aktiven Ansicht; das Popover stellt beides ein (Status und Etappe zum Zeichnen; Filter und Etappe der Ebene — wie die
|
|
// Modelldarstellung ein Feld der Ebene, darum je Reiter/Ausschnitt eigen und mit Undo). Bei wenig Platz wandert es
|
|
// mit der Pausfolie in „⋯“ ([263]).
|
|
|
|
import { useEffect, useRef, useState } from "react";
|
|
import { t } from "../i18n";
|
|
import type { TranslationKey } from "../i18n";
|
|
import { renovationFilterLabel, useRenovationControls, useRenovationSwatches } from "../state/renovationHook";
|
|
import { BUILTIN_RENOVATION_FILTERS, RENOVATION_STATUSES } from "../core";
|
|
import type { RenovationStatus } from "../model/types";
|
|
|
|
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(() => {
|
|
if (!open) return;
|
|
const onDown = (e: MouseEvent) => {
|
|
if (wrapRef.current && !wrapRef.current.contains(e.target as Node)) setOpen(false);
|
|
};
|
|
const onKey = (e: KeyboardEvent) => e.key === "Escape" && setOpen(false);
|
|
document.addEventListener("mousedown", onDown);
|
|
document.addEventListener("keydown", onKey);
|
|
return () => {
|
|
document.removeEventListener("mousedown", onDown);
|
|
document.removeEventListener("keydown", onKey);
|
|
};
|
|
}, [open]);
|
|
const statusLabel = t(`renovation.status.${draw.status}` as TranslationKey);
|
|
const filterLabel = filter ? renovationFilterLabel(filter, own) : t("renovation.filter.none");
|
|
return (
|
|
<span className="sb-snap-wrap" ref={wrapRef}>
|
|
<button
|
|
type="button"
|
|
className={`sb-toggle${open ? " active" : ""}${filter ? " sb-renovation-on" : ""}`}
|
|
data-testid="renovation-toggle"
|
|
aria-haspopup="true"
|
|
aria-expanded={open}
|
|
title={t("renovation.status.hint", { status: statusLabel, filter: filterLabel })}
|
|
onClick={() => setOpen((v) => !v)}
|
|
>
|
|
<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 && (
|
|
<div className="sb-snap-popover sb-renovation-popover" role="dialog" aria-label={t("renovation.title")} data-testid="renovation-panel">
|
|
<div className="sb-snap-row sb-snap-head">{t("renovation.drawStatus")}</div>
|
|
<label className="sb-snap-row sb-snap-row-num">
|
|
<span>{t("renovation.label")}</span>
|
|
<select
|
|
value={draw.status}
|
|
aria-label={t("renovation.drawStatus")}
|
|
data-testid="renovation-draw-status"
|
|
onChange={(e) => setDraw(e.target.value as RenovationStatus, draw.phase)}
|
|
>
|
|
{RENOVATION_STATUSES.map((s) => (
|
|
<option key={s} value={s}>
|
|
{t(`renovation.status.${s}` as TranslationKey)}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</label>
|
|
{phases.length > 0 && (
|
|
<label className="sb-snap-row sb-snap-row-num">
|
|
<span>{t("renovation.phase")}</span>
|
|
<select value={draw.phase ?? ""} aria-label={t("renovation.phase")} onChange={(e) => setDraw(draw.status, e.target.value || undefined)}>
|
|
<option value="">{t("renovation.phase.none")}</option>
|
|
{phases.map((p) => (
|
|
<option key={p.id} value={p.id}>
|
|
{p.name}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</label>
|
|
)}
|
|
<div className="sb-snap-row sb-snap-head">{t("renovation.filter")}</div>
|
|
<label className="sb-snap-row sb-snap-row-num">
|
|
<span>{t("renovation.filter")}</span>
|
|
<select
|
|
value={filter}
|
|
disabled={!levelEditable}
|
|
aria-label={t("renovation.filter")}
|
|
data-testid="renovation-filter"
|
|
onChange={(e) => setLevel({ renovationFilter: e.target.value || undefined, renovationPhase: filterPhase || undefined })}
|
|
>
|
|
<option value="">{t("renovation.filter.none")}</option>
|
|
{BUILTIN_RENOVATION_FILTERS.map((id) => (
|
|
<option key={id} value={id}>
|
|
{t(`renovation.filter.${id}` as TranslationKey)}
|
|
</option>
|
|
))}
|
|
{own.map((f) => (
|
|
<option key={f.id} value={f.id}>
|
|
{f.name}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</label>
|
|
{phases.length > 0 && filter && (
|
|
<label className="sb-snap-row sb-snap-row-num">
|
|
<span>{t("renovation.filterPhase")}</span>
|
|
<select
|
|
value={filterPhase}
|
|
aria-label={t("renovation.filterPhase")}
|
|
onChange={(e) => setLevel({ renovationFilter: filter, renovationPhase: e.target.value || undefined })}
|
|
>
|
|
<option value="">{t("renovation.phase.all")}</option>
|
|
{phases.map((p) => (
|
|
<option key={p.id} value={p.id}>
|
|
{p.name}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</label>
|
|
)}
|
|
</div>
|
|
)}
|
|
</span>
|
|
);
|
|
}
|