mirror of
https://github.com/danbulant/design
synced 2026-05-20 04:38:41 +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" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body>
|
||||
<body class="dark">
|
||||
<div id="svelte">%sveltekit.body%</div>
|
||||
</body>
|
||||
</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
|
||||
// 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
|
||||
const darkmode = writable(
|
||||
typeof window === "undefined" ? false :
|
||||
(JSON.parse(localStorage.getItem("darkmode")) || window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
);
|
||||
// const darkmode = writable(
|
||||
// typeof window === "undefined" ? false :
|
||||
// (JSON.parse(localStorage.getItem("darkmode")) || window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
// );
|
||||
const darkmode = writable(true)
|
||||
|
||||
darkmode.subscribe(v => {
|
||||
if(typeof window !== "undefined")
|
||||
|
|
|
|||
Loading…
Reference in a new issue