diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-11-05 19:25:20 -0500 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-11-05 19:26:28 -0500 |
| commit | fc73108b07e61ab0159ada120f2fb60c430b1d4c (patch) | |
| tree | 4dfb4c5ec52b54f1991532449cbdbd5bb0876835 /ui/routes/+layout.svelte | |
| parent | 2f67205b83009c874f4254a4789b1945668b3056 (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/+layout.svelte')
| -rw-r--r-- | ui/routes/+layout.svelte | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ui/routes/+layout.svelte b/ui/routes/+layout.svelte index d786389..3c2849a 100644 --- a/ui/routes/+layout.svelte +++ b/ui/routes/+layout.svelte @@ -1,20 +1,26 @@ <script> + import { setContext } from 'svelte'; import { onNavigate } from '$app/navigation'; import '../app.css'; import logo from '$lib/assets/logo.png'; import { AppBar } from '@skeletonlabs/skeleton'; - import { showMenu, currentUser } from '$lib/store'; + import { currentUser } from '$lib/store'; import CurrentUser from '$lib/components/CurrentUser.svelte'; + let pageContext = $state({ + showMenu: false + }); + setContext('page', pageContext); + function toggleMenu(event) { event.preventDefault(); - showMenu.update((value) => !value); + pageContext.showMenu = !pageContext.showMenu; } onNavigate(() => { - showMenu.update(() => false); + pageContext.showMenu = false; }); let { children } = $props(); |
