2021-12-09 11:53:54 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import { Router, Link, Route } from "svelte-navigator";
|
2021-12-11 11:00:38 +00:00
|
|
|
import Navigation from "./lib/Navigation.svelte";
|
2021-12-11 11:01:36 +00:00
|
|
|
import Dash from "./pages/Dash.svelte";
|
|
|
|
import Home from "./pages/Home.svelte";
|
2021-12-09 12:56:06 +00:00
|
|
|
|
2021-12-11 10:58:50 +00:00
|
|
|
// theme cdns (I might make some myself too)
|
2021-12-09 12:56:06 +00:00
|
|
|
let light = "https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css";
|
|
|
|
let dark = "https://cdn.jsdelivr.net/npm/bootstrap-dark-5@1.1.3/dist/css/bootstrap-night.min.css";
|
2021-12-09 11:53:54 +00:00
|
|
|
|
2021-12-11 10:58:50 +00:00
|
|
|
let styleSrc = dark;
|
2021-12-09 12:56:06 +00:00
|
|
|
|
2021-12-11 11:00:38 +00:00
|
|
|
// if there's a style already set, retrieve it
|
|
|
|
let style = localStorage.getItem("pk-style") && localStorage.getItem("pk-style");
|
2021-12-09 12:56:06 +00:00
|
|
|
|
2021-12-11 11:00:38 +00:00
|
|
|
// this automatically applies the style every time it is updated
|
|
|
|
$: setStyle(style);
|
2021-12-09 11:53:54 +00:00
|
|
|
|
2021-12-11 11:00:38 +00:00
|
|
|
// not sure if there's a better way to handle this
|
2021-12-09 11:53:54 +00:00
|
|
|
function setStyle(style) {
|
|
|
|
switch (style) {
|
|
|
|
case "light": styleSrc = light;
|
|
|
|
localStorage.setItem("pk-style", "light");
|
|
|
|
break;
|
|
|
|
case "dark": styleSrc = dark;
|
|
|
|
localStorage.setItem("pk-style", "dark");
|
|
|
|
break;
|
2021-12-11 10:58:50 +00:00
|
|
|
default: styleSrc = dark;
|
|
|
|
localStorage.setItem("pk-style", "dark");
|
2021-12-09 11:53:54 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<svelte:head>
|
|
|
|
<link rel="stylesheet" href={styleSrc}>
|
|
|
|
</svelte:head>
|
|
|
|
|
|
|
|
<Router>
|
2021-12-11 11:00:38 +00:00
|
|
|
<Navigation bind:style={style}/>
|
2021-12-09 11:53:54 +00:00
|
|
|
<div>
|
|
|
|
<Route path="/">
|
2021-12-11 11:01:36 +00:00
|
|
|
<Home />
|
|
|
|
</Route>
|
|
|
|
<Route path="/dash">
|
|
|
|
<Dash />
|
2021-12-09 11:53:54 +00:00
|
|
|
</Route>
|
|
|
|
</div>
|
|
|
|
</Router>
|