fix: save choosen color scheme
This commit is contained in:
@@ -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')
|
||||
}
|
||||
|
||||
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user