From a8b9eaed8b971a578fcdba38758a5a09b1f69b8b Mon Sep 17 00:00:00 2001 From: nullptr <62841684+not-nullptr@users.noreply.github.com> Date: Wed, 13 Nov 2024 23:10:47 +0000 Subject: [PATCH] feat: dynamic theme icon (#12) --- .../components/functional/FancyMenu.svelte | 23 +++++- src/routes/+layout.svelte | 80 ++++++++++++++++++- 2 files changed, 97 insertions(+), 6 deletions(-) diff --git a/src/lib/components/functional/FancyMenu.svelte b/src/lib/components/functional/FancyMenu.svelte index 77ef111..e46e618 100644 --- a/src/lib/components/functional/FancyMenu.svelte +++ b/src/lib/components/functional/FancyMenu.svelte @@ -4,6 +4,9 @@ import { duration } from "$lib/animation"; import { quintOut } from "svelte/easing"; import type { Writable } from "svelte/store"; + import clsx from "clsx"; + import { browser } from "$app/environment"; + import { onMount, tick } from "svelte"; interface Props { links: { @@ -16,16 +19,25 @@ let { links, shouldGoBack = null }: Props = $props(); + let hasLoaded = $state(false); + let navWidth = $state(1); let linkCount = $derived(links.length); let activeLinkIndex = $derived( links.findIndex((i) => i.activeMatch($page.url.pathname)), ); + + onMount(async () => { + await tick(); + setTimeout(() => { + hasLoaded = true; + }, 16); + });
{#if activeLinkIndex !== -1}
{/if} {#each links as { name, url } (url)} { if (shouldGoBack) { diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 869aaa7..8bdfe30 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -9,7 +9,7 @@ import { PUB_HOSTNAME, PUB_PLAUSIBLE_URL } from "$env/static/public"; import FancyMenu from "$lib/components/functional/FancyMenu.svelte"; import { writable } from "svelte/store"; - import { SunIcon } from "lucide-svelte"; + import { MoonIcon, SunIcon } from "lucide-svelte"; import { browser } from "$app/environment"; import { setCookie } from "typescript-cookie"; let { children, data } = $props(); @@ -112,8 +112,82 @@
-