From 854b3d84227c6fdd2bf8d9f4ade26ae097f85821 Mon Sep 17 00:00:00 2001 From: Manan Karnik Date: Mon, 12 Feb 2024 22:45:23 +0530 Subject: [PATCH] fix: no colors when signed out --- src/routes/+layout.server.ts | 4 ++++ src/routes/+layout.svelte | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts index ed55dff..50a01da 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -12,4 +12,8 @@ export const load: LayoutServerLoad = async (event) => { secondary: user?.secondary }; } + return { + primary: "fuchsia", + secondary: "violet" + }; }; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index ea9d29d..e8a341e 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -5,6 +5,25 @@ import LoadingBar from "$lib/components/loading-bar.svelte"; import BackgroundGradient from "$lib/components/background-gradient.svelte"; import GithubRibbon from "$lib/components/github-ribbon.svelte"; + import { page } from "$app/stores"; + import { browser } from "$app/environment"; + import { mode } from "mode-watcher"; + import colors from "tailwindcss/colors"; + + if (browser) { + document + .querySelector(":root") + .style.setProperty( + "--primary-color", + colors[$page.data.primary][$mode == "dark" ? 600 : 500] + ); + document + .querySelector(":root") + .style.setProperty( + "--secondary-color", + colors[$page.data.secondary][$mode == "dark" ? 600 : 500] + ); + }