enhanced nav tree

This commit is contained in:
2024-10-11 01:03:27 -05:00
parent 3d89c63f8f
commit 17870927fc
5 changed files with 36 additions and 6 deletions

View File

@ -1,4 +1,29 @@
<li><slot /></li>
<script lang="ts">
import { pane, type Pane } from '$lib/stores/nav';
export let destination: Pane;
function handleKey({ key }: KeyboardEvent) {
if (key === ' ' || key === 'Enter' || key === 'Spacebar') {
navigate();
}
}
function navigate() {
pane.set(destination);
}
</script>
<li
aria-controls="nav-tree"
aria-selected={$pane === destination}
role="tab"
tabindex="0"
on:click={navigate}
on:keyup={handleKey}
>
<slot />
</li>
<style lang="less">
li {

View File

@ -1,5 +1,5 @@
<nav>
<ul>
<ul id="nav-tree" role="tablist">
<slot />
</ul>
</nav>