Skip to content

Commit bd02c85

Browse files
Jappie3sebastinez
authored andcommitted
add event listener to hot reload theme
1 parent b050924 commit bd02c85

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/App.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
2525
const activeRouteStore = router.activeRouteStore;
2626
27+
window
28+
.matchMedia("(prefers-color-scheme: dark)")
29+
.addEventListener("change", ({ matches }) => {
30+
theme.set(matches ? "dark" : "light");
31+
followSystemTheme.set(true);
32+
});
33+
2734
void router.loadFromLocation();
2835
2936
$: document.documentElement.setAttribute("data-codefont", $codeFont);

src/App/Settings.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import Button from "@app/components/Button.svelte";
1212
import Icon from "@app/components/Icon.svelte";
1313
import Radio from "@app/components/Radio.svelte";
14+
1415
</script>
1516

1617
<style>

0 commit comments

Comments
 (0)