Native Selects auf einheitliche Dropdown-Komponente umgestellt
Mehrere Stellen (ResourceManager SelectField + Material-Browser, ImportDialog, AttributesPanel, SitePanel, ToolsPanel, DisplayModeSelect, RichTextEditor) nutzten noch native <select>, deren Optionsliste vom Betriebssystem gerendert wird und optisch nicht zur eigenen Dropdown-Komponente (dunkles Kontextmenü-Popover) passt. Jetzt durchgaengig dieselbe Optik.
This commit is contained in:
@@ -28,6 +28,7 @@ import { formatM } from "../model/types";
|
||||
import { PEN_WEIGHTS } from "../model/types";
|
||||
import type { AttributeSource } from "../model/types";
|
||||
import { usePanelHost } from "./host";
|
||||
import { Dropdown } from "../ui/Dropdown";
|
||||
|
||||
/** UI-Zustand des 3-Optionen-Quellen-Dropdowns (nicht 1:1 das Modell-Feld:
|
||||
* „custom" ist abgeleitet aus „ist ein expliziter Wert gesetzt?", nicht
|
||||
@@ -77,17 +78,17 @@ export function AttributesPanel() {
|
||||
ui: UiSource,
|
||||
onChange: (next: UiSource) => void,
|
||||
) => (
|
||||
<select
|
||||
className="attr-select"
|
||||
style={{ width: 104 }}
|
||||
<Dropdown
|
||||
width={104}
|
||||
value={ui}
|
||||
disabled={!editable}
|
||||
onChange={(e) => onChange(e.target.value as UiSource)}
|
||||
>
|
||||
<option value="layer">{t("attr.source.layer")}</option>
|
||||
<option value="object">{t("attr.source.object")}</option>
|
||||
<option value="custom">{t("attr.source.custom")}</option>
|
||||
</select>
|
||||
onChange={(v) => onChange(v as UiSource)}
|
||||
options={[
|
||||
{ value: "layer", label: t("attr.source.layer") },
|
||||
{ value: "object", label: t("attr.source.object") },
|
||||
{ value: "custom", label: t("attr.source.custom") },
|
||||
]}
|
||||
/>
|
||||
);
|
||||
|
||||
// Farb-Swatch-Eingabe für „eigener Wert" (Vordergrund/Hintergrund). Erscheint
|
||||
@@ -246,19 +247,15 @@ export function AttributesPanel() {
|
||||
fillEditable,
|
||||
hatchUi,
|
||||
onHatchSourceChange,
|
||||
<select
|
||||
className="attr-select"
|
||||
style={{ width: 104 }}
|
||||
<Dropdown
|
||||
width={104}
|
||||
value={sel.fillHatchId ?? ""}
|
||||
onChange={(e) => host.onSetSelectionFill(e.target.value || null)}
|
||||
>
|
||||
<option value="">{t("attr.none")}</option>
|
||||
{project.hatches.map((h) => (
|
||||
<option key={h.id} value={h.id}>
|
||||
{h.name}
|
||||
</option>
|
||||
))}
|
||||
</select>,
|
||||
onChange={(v) => host.onSetSelectionFill(v || null)}
|
||||
options={[
|
||||
{ value: "", label: t("attr.none") },
|
||||
...project.hatches.map((h) => ({ value: h.id, label: h.name })),
|
||||
]}
|
||||
/>,
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
import type { DisplayMode } from "./types";
|
||||
import { t } from "../i18n";
|
||||
import { Dropdown } from "../ui/Dropdown";
|
||||
|
||||
/**
|
||||
* Beschriftungs-Keys je Modus (Werte englisch, vgl. types.ts) — exakt die
|
||||
@@ -41,18 +42,12 @@ export function DisplayModeSelect({
|
||||
}) {
|
||||
const label = title ?? t("display.title");
|
||||
return (
|
||||
<select
|
||||
className="display-mode"
|
||||
<Dropdown
|
||||
triggerClassName="display-mode"
|
||||
value={value}
|
||||
title={label}
|
||||
aria-label={label}
|
||||
onChange={(e) => onChange(e.target.value as DisplayMode)}
|
||||
>
|
||||
{MODE_OPTIONS.map((o) => (
|
||||
<option key={o.value} value={o.value}>
|
||||
{t(o.labelKey)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => onChange(v as DisplayMode)}
|
||||
options={MODE_OPTIONS.map((o) => ({ value: o.value, label: t(o.labelKey) }))}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import type { TranslationKey } from "../i18n";
|
||||
import { usePanelHost } from "./host";
|
||||
import type { ContextObject } from "../model/types";
|
||||
import { ContextImportDialog } from "../ui/ContextImportDialog";
|
||||
import { Dropdown } from "../ui/Dropdown";
|
||||
|
||||
/** Typ-spezifisches Badge-Label (i18n-Key) je Kontext-Objekt-Art. */
|
||||
function typeBadgeKey(obj: ContextObject): TranslationKey {
|
||||
@@ -85,18 +86,12 @@ export function SitePanel() {
|
||||
{contourSets.length > 0 && (
|
||||
<div className="site-terrain-row">
|
||||
{contourSets.length > 1 ? (
|
||||
<select
|
||||
className="site-select"
|
||||
<Dropdown
|
||||
value={effectiveSet}
|
||||
onChange={(e) => setSelectedSet(e.target.value)}
|
||||
aria-label={t("site.contourSet")}
|
||||
>
|
||||
{contourSets.map((cs) => (
|
||||
<option key={cs.id} value={cs.id}>
|
||||
{cs.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => setSelectedSet(v)}
|
||||
title={t("site.contourSet")}
|
||||
options={contourSets.map((cs) => ({ value: cs.id, label: cs.name }))}
|
||||
/>
|
||||
) : (
|
||||
<span className="site-terrain-src" title={t("site.contourSet")}>
|
||||
{contourSets[0].name}
|
||||
|
||||
+15
-18
@@ -13,6 +13,7 @@ import { t } from "../i18n";
|
||||
import { usePanelHost } from "./host";
|
||||
import type { ToolId } from "./host";
|
||||
import { TOOL_ORDER, getTool } from "../tools/tools";
|
||||
import { Dropdown } from "../ui/Dropdown";
|
||||
|
||||
// ── Icons ──────────────────────────────────────────────────────────────────
|
||||
// Keine echten Asset-Icons vorhanden: schlichte Inline-SVG-Glyphen je Werkzeug
|
||||
@@ -153,17 +154,15 @@ export function ToolsPanel() {
|
||||
{host.activeTool === "wall" && (
|
||||
<label className="tools-field">
|
||||
<span>{t("tool.wallType")}</span>
|
||||
<select
|
||||
<Dropdown
|
||||
value={host.activeWallTypeId}
|
||||
disabled={!host.toolsEnabled}
|
||||
onChange={(e) => host.onActiveWallTypeId(e.target.value)}
|
||||
>
|
||||
{host.project.wallTypes.map((wt) => (
|
||||
<option key={wt.id} value={wt.id}>
|
||||
{wt.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => host.onActiveWallTypeId(v)}
|
||||
options={host.project.wallTypes.map((wt) => ({
|
||||
value: wt.id,
|
||||
label: wt.name,
|
||||
}))}
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
|
||||
@@ -174,17 +173,15 @@ export function ToolsPanel() {
|
||||
{host.activeTool === "ceiling" && (
|
||||
<label className="tools-field">
|
||||
<span>{t("tool.ceilingType")}</span>
|
||||
<select
|
||||
<Dropdown
|
||||
value={host.activeWallTypeId}
|
||||
disabled={!host.toolsEnabled}
|
||||
onChange={(e) => host.onActiveWallTypeId(e.target.value)}
|
||||
>
|
||||
{host.project.wallTypes.map((wt) => (
|
||||
<option key={wt.id} value={wt.id}>
|
||||
{wt.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => host.onActiveWallTypeId(v)}
|
||||
options={host.project.wallTypes.map((wt) => ({
|
||||
value: wt.id,
|
||||
label: wt.name,
|
||||
}))}
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
|
||||
|
||||
+10
-16
@@ -9,6 +9,7 @@
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import { docToHtml } from "./renderHtml";
|
||||
import { Dropdown } from "../ui/Dropdown";
|
||||
import {
|
||||
applyMark,
|
||||
applyPreset,
|
||||
@@ -574,15 +575,13 @@ export function RichTextEditor({
|
||||
);
|
||||
|
||||
const handlePreset = useCallback(
|
||||
(e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
const id = e.target.value;
|
||||
(id: string) => {
|
||||
const preset = effectivePresets.find((p) => p.id === id);
|
||||
if (!preset) return;
|
||||
const range = selRange ?? { start: 0, end: 0 };
|
||||
const newDoc = applyPreset(valueRef.current, range, preset);
|
||||
onChangeRef.current(newDoc);
|
||||
setEditorHtml(newDoc, selRange, true);
|
||||
e.target.value = "";
|
||||
},
|
||||
[effectivePresets, selRange, setEditorHtml],
|
||||
);
|
||||
@@ -688,21 +687,16 @@ export function RichTextEditor({
|
||||
|
||||
{/* Presets */}
|
||||
{effectivePresets.length > 0 && (
|
||||
<select
|
||||
className="rt-preset-select"
|
||||
defaultValue=""
|
||||
<Dropdown
|
||||
triggerClassName="rt-preset-select"
|
||||
value=""
|
||||
onChange={handlePreset}
|
||||
title={t("rt.preset")}
|
||||
>
|
||||
<option value="" disabled>
|
||||
{t("rt.preset")} …
|
||||
</option>
|
||||
{effectivePresets.map((p) => (
|
||||
<option key={p.id} value={p.id}>
|
||||
{p.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
options={[
|
||||
{ value: "", label: `${t("rt.preset")} …`, disabled: true },
|
||||
...effectivePresets.map((p) => ({ value: p.id, label: p.label })),
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
+9
-11
@@ -25,6 +25,7 @@ import {
|
||||
distinctLayers,
|
||||
} from "../io/dxfToDrawings";
|
||||
import type { CategoryMode } from "../io/dxfToDrawings";
|
||||
import { Dropdown } from "./Dropdown";
|
||||
|
||||
/** Strukturierte Import-Entscheidung, die der Dialog beim Bestätigen liefert. */
|
||||
export interface ImportDecision {
|
||||
@@ -226,18 +227,15 @@ export function ImportDialog({
|
||||
<span>{t("import.target.existing")}</span>
|
||||
</label>
|
||||
{targetKind === "existing" && (
|
||||
<select
|
||||
className="imp-select"
|
||||
<Dropdown
|
||||
value={existingLevelId}
|
||||
onChange={(e) => setExistingLevelId(e.target.value)}
|
||||
aria-label={t("import.target.existing")}
|
||||
>
|
||||
{project.drawingLevels.map((z) => (
|
||||
<option key={z.id} value={z.id}>
|
||||
{z.name} · {t(kindBadgeKey(z.kind))}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => setExistingLevelId(v)}
|
||||
title={t("import.target.existing")}
|
||||
options={project.drawingLevels.map((z) => ({
|
||||
value: z.id,
|
||||
label: `${z.name} · ${t(kindBadgeKey(z.kind))}`,
|
||||
}))}
|
||||
/>
|
||||
)}
|
||||
<label className="imp-radio">
|
||||
<input
|
||||
|
||||
+21
-30
@@ -43,6 +43,7 @@ import {
|
||||
type AmbientResolution,
|
||||
} from "../materials/ambientcg";
|
||||
import { requestMaterialPreview, cancelMaterialPreview } from "../materials/spherePreview";
|
||||
import { Dropdown } from "./Dropdown";
|
||||
import { EyeIcon } from "./EyeIcon";
|
||||
import { HatchSwatch, LineSwatch, WallTypeSwatch } from "./hatchPreview";
|
||||
import type { SwatchLayer } from "./hatchPreview";
|
||||
@@ -154,7 +155,7 @@ function ColorField({
|
||||
);
|
||||
}
|
||||
|
||||
/** Pill-Dropdown (erbt das globale select-Styling). */
|
||||
/** Pill-Dropdown (nutzt die gemeinsame Dropdown-Komponente statt <select>). */
|
||||
function SelectField<T extends string>({
|
||||
value,
|
||||
onChange,
|
||||
@@ -165,17 +166,11 @@ function SelectField<T extends string>({
|
||||
options: { value: T; label: string }[];
|
||||
}) {
|
||||
return (
|
||||
<select
|
||||
className="res-select"
|
||||
<Dropdown
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value as T)}
|
||||
>
|
||||
{options.map((o) => (
|
||||
<option key={o.value} value={o.value}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
onChange={(v) => onChange(v as T)}
|
||||
options={options}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -623,28 +618,24 @@ function AmbientBrowser({
|
||||
<button className="res-add" onClick={submitSearch}>
|
||||
{t("material.browse.search")}
|
||||
</button>
|
||||
<select
|
||||
className="res-select"
|
||||
<Dropdown
|
||||
value={category}
|
||||
onChange={(e) => setCategory(e.target.value)}
|
||||
>
|
||||
<option value="">{t("material.browse.category.all")}</option>
|
||||
{AMBIENT_CATEGORIES.map((c) => (
|
||||
<option key={c} value={c}>
|
||||
{c}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<select
|
||||
className="res-select"
|
||||
onChange={(v) => setCategory(v)}
|
||||
options={[
|
||||
{ value: "", label: t("material.browse.category.all") },
|
||||
...AMBIENT_CATEGORIES.map((c) => ({ value: c, label: c })),
|
||||
]}
|
||||
/>
|
||||
<Dropdown
|
||||
value={resolution}
|
||||
title={t("material.browse.resolution")}
|
||||
onChange={(e) => setResolution(e.target.value as AmbientResolution)}
|
||||
>
|
||||
<option value="1K">1K</option>
|
||||
<option value="2K">2K</option>
|
||||
<option value="4K">4K</option>
|
||||
</select>
|
||||
onChange={(v) => setResolution(v as AmbientResolution)}
|
||||
options={[
|
||||
{ value: "1K", label: "1K" },
|
||||
{ value: "2K", label: "2K" },
|
||||
{ value: "4K", label: "4K" },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{error && <div className="mat-browse-error">{error}</div>}
|
||||
|
||||
Reference in New Issue
Block a user