2024-10-11 01:03:27 -05:00
|
|
|
<script lang="ts">
|
|
|
|
import { pane, type Pane } from '$lib/stores/nav';
|
|
|
|
|
|
|
|
export let destination: Pane;
|
|
|
|
|
2024-10-11 21:34:00 -05:00
|
|
|
let selected: boolean;
|
2024-10-11 01:45:12 -05:00
|
|
|
$: selected = destination === $pane;
|
|
|
|
|
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-11 01:03:27 -05:00
|
|
|
on:click={navigate}
|
|
|
|
on:keyup={handleKey}
|
|
|
|
>
|
|
|
|
<slot />
|
|
|
|
</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>
|