fix: save choosen color scheme

This commit is contained in:
Pavel Mineev
2022-08-21 22:36:59 -05:00
committed by Umputun
parent b47b6c4f56
commit d6b2960a4a
3 changed files with 6 additions and 5 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
const mq = window.matchMedia('(prefers-color-scheme: dark)')
const theme = localStorage.getItem('theme')
if (mq.matches) {
if ((theme && theme === 'dark') || (!theme && mq.matches)) {
document.documentElement.classList.add('dark')
}
+3 -3
View File
@@ -1,11 +1,11 @@
function toggleTheme() {
const root = document.documentElement
const theme = root.classList.contains('dark') ? 'light' : 'dark'
root.classList.toggle('dark')
localStorage.setItem('theme', theme)
if (window.REMARK42) {
const isDark = root.classList.contains('dark')
window.REMARK42.changeTheme(isDark ? 'dark' : 'light')
window.REMARK42.changeTheme(theme)
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
@apply before:hidden after:hidden text-brand-800 dark:text-brand-300 font-light;
}
.prose strong code {
@apply font-bold text-yellow-600 dark:text-yellow-400;;
@apply font-bold text-yellow-600 dark:text-yellow-400;
}
.burger-icon {