mirror of
https://github.com/danbulant/design
synced 2026-05-24 12:23:57 +00:00
dark mode only
This commit is contained in:
parent
b72498fbbe
commit
8ef657ec02
2 changed files with 6 additions and 5 deletions
|
|
@ -8,7 +8,7 @@
|
||||||
<link rel="stylesheet" href="%sveltekit.assets%/global.css" />
|
<link rel="stylesheet" href="%sveltekit.assets%/global.css" />
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body class="dark">
|
||||||
<div id="svelte">%sveltekit.body%</div>
|
<div id="svelte">%sveltekit.body%</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ import { writable } from "svelte/store";
|
||||||
// it works! But isn't very performant - darkmode is switched after loading the page, not very friendly
|
// it works! But isn't very performant - darkmode is switched after loading the page, not very friendly
|
||||||
// could probably set a cookie and have the class be set in SSR as well, I don't really want to spend the time on that now.
|
// could probably set a cookie and have the class be set in SSR as well, I don't really want to spend the time on that now.
|
||||||
// TODO: make this use cookies and SSR
|
// TODO: make this use cookies and SSR
|
||||||
const darkmode = writable(
|
// const darkmode = writable(
|
||||||
typeof window === "undefined" ? false :
|
// typeof window === "undefined" ? false :
|
||||||
(JSON.parse(localStorage.getItem("darkmode")) || window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
// (JSON.parse(localStorage.getItem("darkmode")) || window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||||
);
|
// );
|
||||||
|
const darkmode = writable(true)
|
||||||
|
|
||||||
darkmode.subscribe(v => {
|
darkmode.subscribe(v => {
|
||||||
if(typeof window !== "undefined")
|
if(typeof window !== "undefined")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue