chore(sfc-playground): add dark mode toggle

This commit is contained in:
Evan You
2021-09-16 14:23:09 -04:00
parent bdb1a7958b
commit 524688bc99
6 changed files with 108 additions and 44 deletions

View File

@@ -9,7 +9,11 @@
<script>
// process shim for old versions of @vue/compiler-sfc dependency
window.process = { env: {} }
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
const saved = localStorage.getItem('vue-sfc-playground-prefer-dark')
if (
saved !== 'false' ||
window.matchMedia('(prefers-color-scheme: dark)').matches
) {
document.documentElement.classList.add('dark')
}
</script>