feat(windkarte): Legend-Toggle — Status ein-/ausblendbar per Klick
Deploy / verify (push) Successful in 54s
Deploy / deploy (push) Successful in 1m1s

Klick auf Legendenitem blendet den Status aus (opacity 0, kein Klick,
kein Hover). Panel schließt sich wenn der Status des gewählten Gebiets
ausgeblendet wird. Visuell: opacity + line-through auf versteckten Items.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Peter Meier
2026-05-13 15:09:14 +02:00
parent 7d4f52ba02
commit 0f6a58fed4
2 changed files with 59 additions and 15 deletions
+24 -12
View File
@@ -21,6 +21,13 @@ let areas = $state<WindArea[]>([]);
let mapReady = $state(false);
let initialGebietsNr = $state<string | null>(null);
let resetMap: (() => void) | null = null;
let hiddenStatuses = $state<string[]>([]);
function toggleStatus(status: string) {
hiddenStatuses = hiddenStatuses.includes(status)
? hiddenStatuses.filter((s) => s !== status)
: [...hiddenStatuses, status];
}
const MapComponent = browser
? import("$lib/components/WindkarteMap.svelte").then((m) => m.default)
@@ -105,6 +112,7 @@ let areas = $state<WindArea[]>([]);
<Map
{areas}
{initialGebietsNr}
{hiddenStatuses}
onselect={handleSelect}
onready={(ctrl) => { resetMap = ctrl.reset; }}
/>
@@ -127,18 +135,22 @@ let areas = $state<WindArea[]>([]);
<!-- Legend -->
<div class="mt-2 flex flex-wrap gap-x-5 gap-y-1.5 text-xs text-stein-400">
<span class="flex items-center gap-1.5">
<span class="inline-block size-2.5 rounded-sm" style="background:#2d7a45; opacity:.7"></span>
{t(T.windkarte_legend_rechtskraeftig)}
</span>
<span class="flex items-center gap-1.5">
<span class="inline-block size-2.5 rounded-sm" style="background:#b08a52; opacity:.7"></span>
{t(T.windkarte_legend_entwurf_2)}
</span>
<span class="flex items-center gap-1.5">
<span class="inline-block size-2.5 rounded-sm" style="background:#d4752a; opacity:.7"></span>
{t(T.windkarte_legend_entwurf_2_voraussichtlich)}
</span>
{#each [
{ status: "rechtskraeftig", color: "#2d7a45", label: t(T.windkarte_legend_rechtskraeftig) },
{ status: "entwurf_2", color: "#b08a52", label: t(T.windkarte_legend_entwurf_2) },
{ status: "entwurf_2_voraussichtlich", color: "#d4752a", label: t(T.windkarte_legend_entwurf_2_voraussichtlich) },
] as item}
<button
type="button"
onclick={() => toggleStatus(item.status)}
class="flex items-center gap-1.5 transition-opacity cursor-pointer select-none
{hiddenStatuses.includes(item.status) ? 'opacity-35' : 'opacity-100'}"
title={hiddenStatuses.includes(item.status) ? 'Einblenden' : 'Ausblenden'}
>
<span class="inline-block size-2.5 rounded-sm shrink-0" style="background:{item.color}; opacity:.7"></span>
<span class="{hiddenStatuses.includes(item.status) ? 'line-through' : ''}">{item.label}</span>
</button>
{/each}
<span class="flex items-center gap-x-3 gap-y-1 flex-wrap text-stein-300">
<span class="text-stein-400">{t(T.windkarte_legend_distances)}</span>
{#each [{ color: "#e35651", label: "200 m" }, { color: "#b08a52", label: "600 m" }, { color: "#436e85", label: "1 km" }] as ring}