Skip to content

Commit

Permalink
export themes as js file in lib, and use footer/header seperatly
Browse files Browse the repository at this point in the history
  • Loading branch information
ehanahamed committed Jan 13, 2025
1 parent 7d89f7d commit b214651
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions web/src/lib/themes.json → web/src/lib/themes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
export default [
"auto",
"dark",
"light"
]
];
8 changes: 5 additions & 3 deletions web/src/routes/+layout.server.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import themesList from "$lib/themes"

export async function load({ cookies }) {
let theme = "auto";
if (cookies.theme !== undefined && themes.includes(cookies.theme)) {
let themeCookie = cookies.get("theme");
if (themeCookie !== undefined && themesList.includes(themeCookie)) {
theme = cookies.theme;
}
let themeCss = `/themes/ehui-${theme}.min.css`;
return {
theme: theme,
themeCss: themeCss
themeCCSSHref: `/themes/ehui-${theme}.min.css`
}
}
4 changes: 1 addition & 3 deletions web/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<script>
let { children, data } = $props();
import Footer from "$lib/components/Footer.svelte";
</script>

<svelte:head>
<link rel="stylesheet" href={ data.themeCss } />
<link rel="stylesheet" href={ data.themeCSSHref } />
</svelte:head>

{@render children()}
<Footer />
11 changes: 10 additions & 1 deletion web/src/routes/dashboard/Dashboard.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<script>
import Header from "$lib/components/Header.svelte";
import Noscript from "$lib/components/Noscript.svelte";
import Footer from "$lib/components/Footer.svelte";
let authed = false;
let data = {};
let { data } = $props();
import { onMount } from "svelte";
onMount(function () {
})
</script>

<Header />
<Noscript />
<main>
<div class="grid page">
Expand Down Expand Up @@ -91,6 +98,8 @@
</div>
</div>
</main>
<Footer />

<script src="/assets/js/fancyTimestamp.js"></script>
<script>
if (window.localStorage && (localStorage.getItem("settingTimeHour") == "24h")) {
Expand Down

0 comments on commit b214651

Please sign in to comment.