Skip to content

Commit

Permalink
Merge pull request #4 from Whbbit1999/main
Browse files Browse the repository at this point in the history
fix: Switching pages will flash #3
  • Loading branch information
kieranwv authored Oct 21, 2024
2 parents d87e874 + 80d9baf commit 7e6b0e1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/ThemeToggle.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
<script lang="ts" setup>
import { useDark, useToggle } from '@vueuse/core'
import { onMounted, watchEffect } from 'vue'
const isDark = useDark()
const toggleDark = useToggle(isDark)
watchEffect(() => {
if (isDark.value) {

Check failure on line 10 in src/components/ThemeToggle.vue

View workflow job for this annotation

GitHub Actions / lint

Unnecessary { after 'if' condition
setDarkMode(document)
}
})
function setDarkMode(document: Document) {
if (isDark.value)
document.documentElement.classList.add('dark')
}
onMounted(() => {
document.addEventListener('astro:before-swap', (event) => {
setDarkMode(event.newDocument)
})
})
function toggleTheme(event: MouseEvent) {
const x = event.clientX
const y = event.clientY
Expand Down

0 comments on commit 7e6b0e1

Please sign in to comment.