Skip to content

Commit

Permalink
fix: dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Nauxscript committed Jan 23, 2024
1 parent 18ecd9d commit 0ca1992
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions apps/client/components/Navbar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ const toggleDarkMode = () => {
document.documentElement.classList.toggle('dark')
}
const setDarkMode = (state = false) => {
if (state) {
document.documentElement.setAttribute("data-theme", "dark");
document.documentElement.classList.add('dark')
} else {
document.documentElement.setAttribute("data-theme", "light");
document.documentElement.classList.remove('dark')
}
}
onMounted(() => {
const state = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
setDarkMode(state)
})
</script>

<template>
Expand Down

0 comments on commit 0ca1992

Please sign in to comment.