docs: use mutation observer to check dark mode class

This commit is contained in:
bcakmakoglu
2022-06-10 21:11:10 +02:00
committed by Braks
parent 9a4c4d6c02
commit 8fd5505eec
2 changed files with 18 additions and 4 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ const npmData = await $fetch('https://api.npmjs.org/downloads/point/last-month/@
</script>
<template>
<div class="w-full dark:(bg-black text-white border-white) border-black border-b-1">
<div class="w-full dark:(bg-black text-white border-white) border-black border-y-1">
<div class="max-w-full md:max-w-11/12 m-auto py-4 md:py-12 <md:(dark:border-t-1 border-white)">
<div class="grid md:grid-cols-3 gap-3 text-center <md:divide-y md:divide-x dark:divide-white divide-black">
<div class="grid grid-rows-auto gap-2 py-4 md:py-0">
+17 -3
View File
@@ -8,8 +8,22 @@ import Heart from '~icons/mdi/heart'
const breakpoints = useBreakpoints(breakpointsTailwind)
const dark = useDark({
selector: 'html',
const dark = ref(false)
onMounted(() => {
const html = document.getElementsByTagName('html')![0]
const observer = new MutationObserver((mutations) => {
for (const m of mutations) {
dark.value = html.classList.contains('dark')
}
})
observer.observe(html, {
attributes: true,
attributeOldValue: true,
attributeFilter: ['class'],
})
})
const initialEdges = [
@@ -206,7 +220,7 @@ const scrollTo = () => {
<template>
<VueFlow ref="el" class="dark:bg-black bg-white transition-colors duration-200 ease-in-out">
<Background variant="lines" :size="0.7" :gap="100" />
<Background variant="lines" :pattern-color="dark ? '#ffffff' : '#000000'" :size="0.7" :gap="100" />
<template #node-box="props">
<template v-if="props.id === 'intro'">