Skip to content
Snippets Groups Projects
Commit 48589d49 authored by Linus Keiser's avatar Linus Keiser :speech_balloon:
Browse files

simplify layout (bars fixed instead of sticky with scrolling main content)

parent 3d70c738
No related branches found
No related tags found
1 merge request!312feat/layout
...@@ -13,36 +13,27 @@ ...@@ -13,36 +13,27 @@
import { sidebarState } from '$lib/stores/layout.svelte'; import { sidebarState } from '$lib/stores/layout.svelte';
import { Navigation } from '@skeletonlabs/skeleton-svelte'; import { Navigation } from '@skeletonlabs/skeleton-svelte';
let { classes = 'sticky top-0 col-span-1 h-screen' }: { classes?: string } = $props(); // let { classes = 'sticky top-0 col-span-1 h-screen' }: { classes?: string } = $props();
let expandedText = $derived(sidebarState.isOpen ? 'Collapse' : 'Expand'); // let expandedText = $derived(sidebarState.isOpen ? 'Collapse' : 'Expand');
// let expandedIcon = $derived(expanded ? PanelRightCloseIcon : PanelRightOpenIcon); // let expandedIcon = $derived(expanded ? PanelRightCloseIcon : PanelRightOpenIcon);
</script> </script>
<!-- TODO ensure active tile stays active after page reload --> <!-- TODO ensure active tile stays active after page reload -->
<Navigation.Rail <Navigation.Rail expanded={sidebarState.isOpen}>
expanded={sidebarState.isOpen}
height="h-screen"
base=""
classes="sticky top-0 col-span-1 "
>
{#snippet header()} {#snippet header()}
<!-- TODO improve collapse/expand button styling and positioning --> <!-- TODO improve collapse/expand button styling and positioning -->
<!--<div> <button onclick={() => (sidebarState.isOpen = !sidebarState.isOpen)} class="btn btn-sm w-full">
<button onclick={() => (sidebarState.isOpen = !sidebarState.isOpen)} class="btn btn-sm"> {#if sidebarState.isOpen}
{#if sidebarState.isOpen} <ChevronLeft />
<ChevronLeft /> {:else}
{:else} <ChevronRight />
<ChevronRight /> {/if}
{/if} </button>
</button>
</div>
-->
<Navigation.Tile id="header-tile" title="Home" labelExpanded="Home" href="/"> <Navigation.Tile id="header-tile" title="Home" labelExpanded="Home" href="/">
<HomeIcon /> <HomeIcon />
</Navigation.Tile> </Navigation.Tile>
<!--</button> -->
{/snippet} {/snippet}
{#snippet tiles()} {#snippet tiles()}
<!-- TODO improve visual item grouping for items with children --> <!-- TODO improve visual item grouping for items with children -->
......
<script lang="ts"> <script lang="ts">
import { page } from '$app/state';
import SideBar from '$lib/components/SideBar.svelte'; import SideBar from '$lib/components/SideBar.svelte';
import ThemeToggle from '$lib/components/ThemeToggle.svelte'; import ThemeToggle from '$lib/components/ThemeToggle.svelte';
import { onMount } from 'svelte';
let { children } = $props(); let { children } = $props();
let headerElement: HTMLElement | null = null; // let headerElement: HTMLElement | null = null;
let headerHeight: number | null = $state(null); // let headerHeight: number | null = $state(null);
onMount(() => { // onMount(() => {
const updateHeaderHeight = () => { // const updateHeaderHeight = () => {
if (headerElement !== null) { // if (headerElement !== null) {
headerHeight = headerElement.offsetHeight; // headerHeight = headerElement.offsetHeight;
} // }
}; // };
updateHeaderHeight(); // updateHeaderHeight();
window.addEventListener('resize', updateHeaderHeight); // window.addEventListener('resize', updateHeaderHeight);
return () => { // return () => {
window.removeEventListener('resize', updateHeaderHeight); // window.removeEventListener('resize', updateHeaderHeight);
}; // };
}); // });
</script> </script>
<div class="grid grid-rows-[auto_1fr_auto]"> <div class="grid h-screen grid-rows-[auto_1fr_auto]">
<!-- Header Bar --> <!-- Header -->
<header <header
bind:this={headerElement}
class="text-slate-50-950 grid grid-cols-3 items-center gap-4 px-4 py-2 bg-primary-200-800" class="text-slate-50-950 grid grid-cols-3 items-center gap-4 px-4 py-2 bg-primary-200-800"
> >
<div class="justify-self-start"> <div class="justify-self-start">
...@@ -41,20 +38,22 @@ ...@@ -41,20 +38,22 @@
<div class="justify-self-center text-xl">(Page Title/breadcrumbs?)</div> <div class="justify-self-center text-xl">(Page Title/breadcrumbs?)</div>
<div class="justify-self-end"><ThemeToggle /></div> <div class="justify-self-end"><ThemeToggle /></div>
</header> </header>
<!--<nav>(subheader/trail nav)</nav>-->
<!-- Page -->
<div class="grid grid-cols-[auto_1fr]"> <!-- Grid Columns -->
<!-- Side Bar (subtract header height since it's sticky, too) --> <div class="grid grid-cols-1 overflow-hidden md:grid-cols-[auto_1fr]">
<!--<SideBar classes="sticky top-0 col-span-1 h-[calc(100vh-{headerHeight}px)]" /> --> <!-- Sidebar -->
<!-- TODO change for small screen sizes -->
<aside class="sticky top-0 col-span-1 h-screen bg-yellow-500 p-4">(sidebar)</aside> <!-- h-full? apply h-screen if sticky -->
<SideBar />
<!-- Page Route Content -->
<main class="col-span-1 space-y-4 p-2 bg-surface-200-800">{@render children?.()}</main> <!-- main + footer container (so that the footer scrolls into view after main) -->
<main class="space-y-4 overflow-y-auto p-4 bg-surface-200-800">
{@render children?.()}
</main>
</div> </div>
<!-- Footer --> <!-- Footer -->
<footer class="bg-blue-500 p-4">(footer)</footer> <!--<footer class="bg-blue-500 p-4">(footer)</footer>-->
</div> </div>
<style lang="postcss"> <style lang="postcss">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment