refactor: Zeitraum-Dropdown in DetailModal auf Listbox mit Littwin-Design umgestellt

- <select> durch Headless UI Listbox ersetzt
- Optionen DIA0, DIA1, DIA2 mit deutschem Label dargestellt
- Einheitliches Styling mit littwin-blue wie in anderen Komponenten
This commit is contained in:
ISA
2025-07-08 07:09:27 +02:00
parent 3af16b4c29
commit 44cfd2ab81
6 changed files with 69 additions and 18 deletions

View File

@@ -4,6 +4,7 @@ import React from "react";
import { Line } from "react-chartjs-2";
import { useSelector } from "react-redux";
import { RootState } from "@/redux/store";
import { Listbox } from "@headlessui/react";
type Props = {
isOpen: boolean;
@@ -78,19 +79,59 @@ export const DetailModal = ({
</button>
</div>
<div className="mb-4">
<label className="mr-2 font-medium">Zeitraum:</label>
<select
className="border px-2 py-1 rounded"
value={zeitraum}
onChange={(e) =>
setZeitraum(e.target.value as "DIA0" | "DIA1" | "DIA2")
}
>
<option value="DIA0">Alle Messwerte</option>
<option value="DIA1">Stündlich</option>
<option value="DIA2">Täglich</option>
</select>
<div className="flex items-center space-x-2 mb-4">
<label className="font-medium">Zeitraum:</label>
<Listbox value={zeitraum} onChange={setZeitraum}>
<div className="relative w-48">
<Listbox.Button className="w-full border px-3 py-1 rounded text-left bg-white flex justify-between items-center text-sm">
<span>
{
{
DIA0: "Alle Messwerte",
DIA1: "Stündlich",
DIA2: "Täglich",
}[zeitraum]
}
</span>
<svg
className="w-5 h-5 text-gray-400"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fillRule="evenodd"
d="M5.23 7.21a.75.75 0 011.06.02L10 10.585l3.71-3.355a.75.75 0 111.02 1.1l-4.25 3.85a.75.75 0 01-1.02 0l-4.25-3.85a.75.75 0 01.02-1.06z"
clipRule="evenodd"
/>
</svg>
</Listbox.Button>
<Listbox.Options className="absolute z-50 mt-1 w-full border rounded bg-white shadow max-h-60 overflow-auto text-sm">
{["DIA0", "DIA1", "DIA2"].map((option) => (
<Listbox.Option
key={option}
value={option}
className={({ selected, active }) =>
`px-4 py-1 cursor-pointer ${
selected
? "bg-littwin-blue text-white"
: active
? "bg-blue-100"
: ""
}`
}
>
{
{
DIA0: "Alle Messwerte",
DIA1: "Stündlich",
DIA2: "Täglich",
}[option]
}
</Listbox.Option>
))}
</Listbox.Options>
</div>
</Listbox>
</div>
<div className="h-[85%]">