Skip to content

Commit

Permalink
fix darkMode theme on apps
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfiszel committed Nov 26, 2024
1 parent e92750c commit 66235c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions frontend/src/lib/components/apps/editor/AppEditorHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -875,15 +875,15 @@
const dispatch = createEventDispatcher()
function setTheme(newDarkMode: boolean | undefined) {
if (
newDarkMode === true ||
(newDarkMode === null && window.localStorage.getItem('dark-mode') === 'dark')
) {
let globalDarkMode = window.localStorage.getItem('dark-mode')
? window.localStorage.getItem('dark-mode') === 'dark'
: window.matchMedia('(prefers-color-scheme: dark)').matches
if (newDarkMode === true || (newDarkMode === null && globalDarkMode)) {
document.documentElement.classList.add('dark')
} else if (newDarkMode === false) {
document.documentElement.classList.remove('dark')
}
$darkMode = newDarkMode ?? false
$darkMode = newDarkMode ?? globalDarkMode
}
let priorDarkMode = document.documentElement.classList.contains('dark')
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/lib/components/apps/editor/AppPreview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@
})
function setTheme(darkMode: boolean | undefined) {
if (
darkMode === true ||
(darkMode === null && window.localStorage.getItem('dark-mode') === 'dark')
) {
let globalDarkMode = window.localStorage.getItem('dark-mode')
? window.localStorage.getItem('dark-mode') === 'dark'
: window.matchMedia('(prefers-color-scheme: dark)').matches
if (darkMode === true || (darkMode === null && globalDarkMode)) {
document.documentElement.classList.add('dark')
} else if (darkMode === false) {
document.documentElement.classList.remove('dark')
Expand Down

0 comments on commit 66235c0

Please sign in to comment.