1
0
resumarkdown/src/lib/components/nav-item.svelte

53 lines
921 B
Svelte
Raw Normal View History

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 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-11 01:36:09 -05:00
font-weight: 600;
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;
}
li.selected {
background-color: darken(@color-light, 20%);
}
li:focus,
li:hover {
background-color: darken(@color-light, 10%);
2024-10-11 00:23:32 -05:00
}
li:not(:last-of-type) {
border-bottom: 1px solid @color-dark;
}
</style>