PluralKit/src/App.svelte

47 lines
1.2 KiB
Svelte
Raw Normal View History

2021-12-09 11:53:54 +00:00
<script lang="ts">
import { onMount } from "svelte";
import { Router, Link, Route } from "svelte-navigator";
import Navigation from "./lib/Navigation.svelte";
2021-12-09 11:53:54 +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 11:53:54 +00:00
onMount(() => {
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 11:53:54 +00:00
function setStyle(style) {
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>
<Navigation on:styleChange={styleEventHandler}/>
2021-12-09 11:53:54 +00:00
<div>
<Route path="/">
<h2>Ooga booga</h2>
</Route>
</div>
</Router>