diff --git a/site/src/includes/inline.js b/site/src/includes/inline.js index b4009db8af..45ab1bd532 100644 --- a/site/src/includes/inline.js +++ b/site/src/includes/inline.js @@ -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') } diff --git a/site/src/includes/script.js b/site/src/includes/script.js index 0251502657..cef2c14ae0 100644 --- a/site/src/includes/script.js +++ b/site/src/includes/script.js @@ -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) } } diff --git a/site/src/styles.css b/site/src/styles.css index 2ece27f316..569914e132 100644 --- a/site/src/styles.css +++ b/site/src/styles.css @@ -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 {