export default function LayerPanel () {
const [data] = getData();
const [selectedSource, setSelectedSource] = createSignal("");
const SourceDropdown = () => {
if (data.state === "ready") {
const sources = parseModelData(data()).getSources();
const sourcesPair = sources.map(source => {
return {
[source]: SOURCE_LOOKUP[source]
}
});
return (
<>
<div class="dropdown">
<button class="btn btn-sm" type="button" data-bs-toggle="dropdown" aria-expanded="false">
{ selectedSource() ? SOURCE_LOOKUP[selectedSource()] : "Select source..." }
</button>
<ul class="dropdown-menu">
<For each={ sourcesPair } fallback={"Loading..."}>
{(source) => <li><a onClick={
(event) => {
const value = event.currentTarget.textContent || "";
const key = Object.keys(SOURCE_LOOKUP).find(key => SOURCE_LOOKUP[key] === value);
setSelectedSource(key || "default");
}
} class="dropdown-item">{Object.values(source)}</a></li>}
</For>
</ul>
</div>
</>
)
}
}