persist tab pane state, handle vertical scrolling in tab pane

This commit is contained in:
Ennea
2025-10-01 16:35:27 +02:00
parent 2cdc5bfcd9
commit 9f097b4df3
5 changed files with 33 additions and 12 deletions
@@ -1,5 +1,5 @@
<script lang="ts">
import { selectedTab, knownTabs, tabBarState } from "$lib/shared.svelte";
import { selectedTab, knownTabs, tabPaneState, closeTabPane } from "$lib/shared.svelte";
async function selectTab(index: number) {
const rawResponse = await fetch('/tab', {
@@ -13,17 +13,13 @@
// const content = await rawResponse.json();
// TODO: use the response
}
function closeTabBar() {
tabBarState.visible = false;
}
</script>
<aside id="tabs" class:visible={tabBarState.visible}>
<aside id="tabs" class:visible={tabPaneState.visible}>
<div class="inner">
<header>
<span>Tabs</span>
<button type="button" onclick={() => closeTabBar()}>
<button type="button" onclick={() => closeTabPane()}>
<!-- "x" icon from https://github.com/feathericons/feather, under MIT license -->
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</button>
@@ -1,12 +1,13 @@
<script lang="ts">
import { tabBarState } from "$lib/shared.svelte";
import { tabPaneState, openTabPane } from "$lib/shared.svelte";
function onclick() {
tabBarState.visible = true;
openTabPane();
}
</script>
<button type="button" aria-label="Open tab pane" class:visible={!tabBarState.visible} {onclick}>
<button type="button" aria-label="Open tab pane" class:visible={!tabPaneState.visible} {onclick} disabled={tabPaneState.visible}>
<!-- "chevron-right" icon from https://github.com/feathericons/feather, under MIT license -->
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>
</button>