2023-06-23 17:23:14 +02:00
|
|
|
<script lang=ts>
|
|
|
|
import "$lib/components/nordtheme.css"
|
2023-06-24 15:31:10 +02:00
|
|
|
import { season } from '$lib/js/season_store.js'
|
2023-06-23 17:23:14 +02:00
|
|
|
import {onMount} from "svelte";
|
2023-06-25 10:17:12 +02:00
|
|
|
import {do_on_key} from "./do_on_key";
|
2023-06-23 17:23:14 +02:00
|
|
|
let months = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"]
|
|
|
|
|
2023-06-24 15:31:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
let season_local
|
|
|
|
|
|
|
|
season.subscribe((s) => {
|
|
|
|
season_local = s
|
|
|
|
});
|
2023-06-23 17:23:14 +02:00
|
|
|
|
|
|
|
export function set_season(){
|
|
|
|
let temp = []
|
|
|
|
const el = document.getElementById("labels");
|
|
|
|
for(var i = 0; i < el.children.length; i++){
|
|
|
|
if(el.children[i].children[0].children[0].checked){
|
|
|
|
temp.push(i+1)
|
|
|
|
}
|
|
|
|
}
|
2023-06-24 15:31:10 +02:00
|
|
|
season.update((s) => temp)
|
2023-06-23 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function write_season(season){
|
|
|
|
const el = document.getElementById("labels");
|
|
|
|
for(var i = 0; i < season.length; i++){
|
2023-06-24 15:31:10 +02:00
|
|
|
el.children[season[i]-1].children[0].children[0].checked = true
|
2023-06-23 17:23:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-25 10:17:12 +02:00
|
|
|
function toggle_checkbox_on_key(event){
|
|
|
|
event.path[0].children[0].checked = !event.path[0].children[0].checked
|
|
|
|
}
|
2023-06-23 17:23:14 +02:00
|
|
|
onMount(() => {
|
2023-06-24 15:31:10 +02:00
|
|
|
write_season(season_local)
|
2023-06-23 17:23:14 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
<style>
|
|
|
|
label{
|
|
|
|
background-color: var(--nord0);
|
|
|
|
color: white;
|
|
|
|
padding: 0.25em 1em;
|
|
|
|
border-radius: 1000px;
|
|
|
|
cursor: pointer;
|
|
|
|
position: relative;
|
|
|
|
transition: 100ms;
|
2023-06-25 10:17:12 +02:00
|
|
|
user-select: none;
|
2023-06-23 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.checkbox_container{
|
|
|
|
transition: 100ms;
|
|
|
|
}
|
2023-06-25 10:17:12 +02:00
|
|
|
.checkbox_container:hover,
|
|
|
|
.checkbox_container:focus-within
|
|
|
|
{
|
2023-06-23 17:23:14 +02:00
|
|
|
transform: scale(1.1,1.1);
|
|
|
|
}
|
2023-06-25 10:17:12 +02:00
|
|
|
label:hover,
|
|
|
|
label:focus-visible
|
|
|
|
{
|
2023-06-23 17:23:14 +02:00
|
|
|
background-color: var(--lightblue);
|
|
|
|
}
|
|
|
|
|
|
|
|
label:has(input:checked){
|
|
|
|
background-color: var(--blue);
|
|
|
|
}
|
|
|
|
input[type=checkbox],
|
|
|
|
input[type=checkbox]::before,
|
|
|
|
input[type=checkbox]::after
|
|
|
|
{
|
|
|
|
all: unset;
|
2023-06-25 10:17:12 +02:00
|
|
|
user-select: none;
|
2023-06-23 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#labels{
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: center;
|
|
|
|
gap: min(1rem, 1dvh);
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<div id=labels>
|
|
|
|
{#each months as month}
|
|
|
|
<div class=checkbox_container>
|
2023-07-03 00:09:00 +02:00
|
|
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex-->
|
|
|
|
<label tabindex="0" on:keydown={(event) => do_on_key(event, 'Enter', false, () => {toggle_checkbox_on_key(event)}) } ><input tabindex=-1 type="checkbox" name="checkbox" value="value" on:click={set_season}>{month}</label>
|
2023-06-23 17:23:14 +02:00
|
|
|
</div>
|
|
|
|
{/each}
|
|
|
|
</div>
|