Skip to content

Instantly share code, notes, and snippets.

View liborvanek's full-sized avatar

Libor Vaněk liborvanek

View GitHub Profile
@evdama
evdama / ThemeToggle.svelte
Created August 5, 2019 17:50
how to move the window.matchMedia to <svelte:window>
<script>
import { onMount } from 'svelte';
let html, currentColorScheme = 'light';
onMount(
() => {
html = document.getElementsByTagName('html')[0]
window.matchMedia('(prefers-color-scheme: dark)').addListener(({ matches }) => {
if (matches) {