summaryrefslogtreecommitdiff
path: root/ui/routes/(app)/+layout.svelte
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-11-05 19:25:20 -0500
committerOwen Jacobson <owen@grimoire.ca>2024-11-05 19:26:28 -0500
commitfc73108b07e61ab0159ada120f2fb60c430b1d4c (patch)
tree4dfb4c5ec52b54f1991532449cbdbd5bb0876835 /ui/routes/(app)/+layout.svelte
parent2f67205b83009c874f4254a4789b1945668b3056 (diff)
Move `showMenu` out of globals and into page state.
I generally don't love globals, and the scope of this global is pretty narrow. Let's use the context hierarchy for this, instead. (Kit mentioned that it might be possible to use CSS variables for this.)
Diffstat (limited to 'ui/routes/(app)/+layout.svelte')
-rw-r--r--ui/routes/(app)/+layout.svelte7
1 files changed, 4 insertions, 3 deletions
diff --git a/ui/routes/(app)/+layout.svelte b/ui/routes/(app)/+layout.svelte
index ae3dc6a..0a8c58d 100644
--- a/ui/routes/(app)/+layout.svelte
+++ b/ui/routes/(app)/+layout.svelte
@@ -1,16 +1,17 @@
<script>
import { page } from '$app/stores';
import { goto } from '$app/navigation';
- import { onMount, onDestroy } from 'svelte';
+ import { onMount, onDestroy, getContext } from 'svelte';
import { boot, subscribeToEvents } from '$lib/apiServer';
- import { showMenu, currentUser, logins, channelsList, messages } from '$lib/store';
+ import { currentUser, logins, channelsList, messages } from '$lib/store';
import ChannelList from '$lib/components/ChannelList.svelte';
import CreateChannelForm from '$lib/components/CreateChannelForm.svelte';
let events = null;
+ let pageContext = getContext('page');
let { children } = $props();
let loading = $state(true);
let channel = $derived($page.params.channel);
@@ -62,7 +63,7 @@
<h2>Loading&hellip;</h2>
{:else}
<div id="interface" class="p-2">
- <nav id="sidebar" data-expanded={$showMenu}>
+ <nav id="sidebar" data-expanded={pageContext.showMenu}>
<div class="channel-list">
<ChannelList active={channel} channels={$channelsList.channels} />
</div>