docs: use mutation observer to check dark mode class
This commit is contained in:
@@ -8,7 +8,7 @@ const npmData = await $fetch('https://api.npmjs.org/downloads/point/last-month/@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<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="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 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">
|
<div class="grid grid-rows-auto gap-2 py-4 md:py-0">
|
||||||
|
|||||||
@@ -8,8 +8,22 @@ import Heart from '~icons/mdi/heart'
|
|||||||
|
|
||||||
const breakpoints = useBreakpoints(breakpointsTailwind)
|
const breakpoints = useBreakpoints(breakpointsTailwind)
|
||||||
|
|
||||||
const dark = useDark({
|
const dark = ref(false)
|
||||||
selector: 'html',
|
|
||||||
|
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 = [
|
const initialEdges = [
|
||||||
@@ -206,7 +220,7 @@ const scrollTo = () => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VueFlow ref="el" class="dark:bg-black bg-white transition-colors duration-200 ease-in-out">
|
<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 #node-box="props">
|
||||||
<template v-if="props.id === 'intro'">
|
<template v-if="props.id === 'intro'">
|
||||||
|
|||||||
Reference in New Issue
Block a user