2021-12-09 11:53:54 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import { onMount } from "svelte";
|
|
|
|
import { Router, Link, Route } from "svelte-navigator";
|
2021-12-09 12:56:06 +00:00
|
|
|
import Navigation from "./lib/Navigation.svelte";
|
|
|
|
|
2021-12-09 11:53:54 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
let styleSrc = light;
|
2021-12-09 12:56:06 +00:00
|
|
|
|
2021-12-09 11:53:54 +00:00
|
|
|
onMount(() => {
|
2021-12-09 12:56:06 +00:00
|
|
|
if (localStorage.getItem("pk-style")) setStyle(localStorage.getItem("pk-style").toLowerCase());
|
|
|
|
});
|
|
|
|
|
|
|
|
function styleEventHandler(event) {
|
|
|
|
let style = event.detail;
|
2021-12-09 11:53:54 +00:00
|
|
|
setStyle(style);
|
2021-12-09 12:56:06 +00:00
|
|
|
}
|
2021-12-09 11:53:54 +00:00
|
|
|
|
|
|
|
function setStyle(style) {
|
2021-12-09 12:56:06 +00:00
|
|
|
|
2021-12-09 11:53:54 +00:00
|
|
|
switch (style) {
|
|
|
|
case "light": styleSrc = light;
|
|
|
|
localStorage.setItem("pk-style", "light");
|
|
|
|
break;
|
|
|
|
case "dark": styleSrc = dark;
|
|
|
|
localStorage.setItem("pk-style", "dark");
|
|
|
|
break;
|
|
|
|
default: styleSrc = light;
|
|
|
|
localStorage.setItem("pk-style", "light");
|
|
|
|
};
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<svelte:head>
|
|
|
|
<link rel="stylesheet" href={styleSrc}>
|
|
|
|
</svelte:head>
|
|
|
|
|
|
|
|
<Router>
|
2021-12-09 12:56:06 +00:00
|
|
|
<Navigation on:styleChange={styleEventHandler}/>
|
2021-12-09 11:53:54 +00:00
|
|
|
<div>
|
|
|
|
<Route path="/">
|
|
|
|
<h2>Ooga booga</h2>
|
|
|
|
</Route>
|
|
|
|
</div>
|
|
|
|
</Router>
|