2024-10-11 01:03:27 -05:00
|
|
|
<script lang="ts">
|
2024-10-16 12:36:50 -05:00
|
|
|
import { type Snippet } from 'svelte';
|
2024-10-11 01:03:27 -05:00
|
|
|
|
2024-10-16 12:36:50 -05:00
|
|
|
import { pane, type Pane } from '$lib/stores/nav.js';
|
2024-10-11 01:03:27 -05:00
|
|
|
|
2024-10-16 12:36:50 -05:00
|
|
|
interface Props {
|
|
|
|
destination: Pane;
|
|
|
|
children: Snippet;
|
|
|
|
}
|
|
|
|
|
|
|
|
let { destination, children }: Props = $props();
|
|
|
|
|
|
|
|
let selected: boolean = $derived(destination === $pane);
|
2024-10-11 01:45:12 -05:00
|
|
|
|
2024-10-11 01:03:27 -05:00
|
|
|
function handleKey({ key }: KeyboardEvent) {
|
|
|
|
if (key === ' ' || key === 'Enter' || key === 'Spacebar') {
|
|
|
|
navigate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function navigate() {
|
|
|
|
pane.set(destination);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<li
|
2024-10-11 21:26:16 -05:00
|
|
|
aria-controls={`pane-${destination}`}
|
2024-10-11 01:45:12 -05:00
|
|
|
aria-selected={selected}
|
2024-10-11 01:03:27 -05:00
|
|
|
role="tab"
|
|
|
|
tabindex="0"
|
2024-10-11 01:45:12 -05:00
|
|
|
class:selected
|
2024-10-16 12:36:50 -05:00
|
|
|
onclick={navigate}
|
|
|
|
onkeyup={handleKey}
|
2024-10-11 01:03:27 -05:00
|
|
|
>
|
2024-10-16 12:36:50 -05:00
|
|
|
{@render children()}
|
2024-10-11 01:03:27 -05:00
|
|
|
</li>
|
2024-10-11 00:23:32 -05:00
|
|
|
|
|
|
|
<style lang="less">
|
|
|
|
li {
|
2024-10-12 23:47:09 -05:00
|
|
|
@separator: 1px solid @color-dark;
|
|
|
|
|
|
|
|
font-weight: @font-w-semibold;
|
2024-10-11 00:23:32 -05:00
|
|
|
margin: 0;
|
|
|
|
padding: @padding-md;
|
|
|
|
text-align: center;
|
2024-10-11 01:45:12 -05:00
|
|
|
transition: background-color 0.2s;
|
|
|
|
|
2024-10-11 22:59:30 -05:00
|
|
|
&.selected {
|
|
|
|
background-color: darken(@color-light, 20%);
|
|
|
|
}
|
2024-10-11 01:45:12 -05:00
|
|
|
|
2024-10-11 22:59:30 -05:00
|
|
|
&:focus,
|
|
|
|
&:hover {
|
|
|
|
background-color: darken(@color-light, 10%);
|
|
|
|
}
|
2024-10-11 00:23:32 -05:00
|
|
|
|
2024-10-11 22:59:30 -05:00
|
|
|
&:not(:last-of-type) {
|
2024-10-11 23:10:25 -05:00
|
|
|
border-bottom: @separator;
|
2024-10-12 23:47:09 -05:00
|
|
|
}
|
2024-10-11 23:10:25 -05:00
|
|
|
|
2024-10-12 23:47:09 -05:00
|
|
|
@media screen and (min-width: @sizes[lg]) {
|
|
|
|
flex: 1;
|
2024-10-12 11:57:58 -05:00
|
|
|
|
2024-10-12 23:47:09 -05:00
|
|
|
&:not(:last-of-type) {
|
|
|
|
border-bottom: none;
|
|
|
|
border-right: @separator;
|
2024-10-11 23:10:25 -05:00
|
|
|
}
|
2024-10-11 22:59:30 -05:00
|
|
|
}
|
2024-10-11 00:23:32 -05:00
|
|
|
}
|
|
|
|
</style>
|