2023-11-12 16:42:57 +00:00
|
|
|
<script setup lang="ts">
|
2024-01-25 16:32:45 +00:00
|
|
|
import DefaultTheme from 'vitepress/theme'
|
|
|
|
import { useData } from 'vitepress'
|
|
|
|
import { nextTick, provide } from 'vue'
|
|
|
|
import Sidebar from './components/SidebarCard.vue'
|
|
|
|
import Announcement from './components/Announcement.vue'
|
2023-12-23 03:02:38 +00:00
|
|
|
|
2024-01-25 16:32:45 +00:00
|
|
|
const { isDark } = useData()
|
2023-12-23 03:02:38 +00:00
|
|
|
|
|
|
|
const enableTransitions = () =>
|
2024-01-25 16:32:45 +00:00
|
|
|
'startViewTransition' in document &&
|
|
|
|
window.matchMedia('(prefers-reduced-motion: no-preference)').matches
|
2023-12-23 03:02:38 +00:00
|
|
|
|
2024-01-25 16:32:45 +00:00
|
|
|
provide('toggle-appearance', async ({ clientX: x, clientY: y }: MouseEvent) => {
|
2023-12-23 03:02:38 +00:00
|
|
|
if (!enableTransitions()) {
|
2024-01-25 16:32:45 +00:00
|
|
|
isDark.value = !isDark.value
|
|
|
|
return
|
2023-12-23 03:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const clipPath = [
|
|
|
|
`circle(0px at ${x}px ${y}px)`,
|
|
|
|
`circle(${Math.hypot(
|
|
|
|
Math.max(x, innerWidth - x),
|
2024-01-25 16:32:45 +00:00
|
|
|
Math.max(y, innerHeight - y)
|
|
|
|
)}px at ${x}px ${y}px)`
|
|
|
|
]
|
2023-12-23 03:02:38 +00:00
|
|
|
|
|
|
|
// @ts-expect-error
|
|
|
|
await document.startViewTransition(async () => {
|
2024-01-25 16:32:45 +00:00
|
|
|
isDark.value = !isDark.value
|
|
|
|
await nextTick()
|
|
|
|
}).ready
|
2023-12-23 03:02:38 +00:00
|
|
|
|
|
|
|
document.documentElement.animate(
|
|
|
|
{ clipPath: isDark.value ? clipPath.reverse() : clipPath },
|
|
|
|
{
|
|
|
|
duration: 300,
|
2024-01-25 16:32:45 +00:00
|
|
|
easing: 'ease-in',
|
|
|
|
pseudoElement: `::view-transition-${isDark.value ? 'old' : 'new'}(root)`
|
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
2023-11-12 16:42:57 +00:00
|
|
|
|
2024-01-25 16:32:45 +00:00
|
|
|
const { Layout } = DefaultTheme
|
2023-11-12 16:42:57 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<Layout>
|
|
|
|
<template #sidebar-nav-after>
|
|
|
|
<Sidebar />
|
|
|
|
</template>
|
|
|
|
<template #home-hero-prelink>
|
|
|
|
<Announcement />
|
|
|
|
</template>
|
|
|
|
<Content />
|
|
|
|
</Layout>
|
|
|
|
</template>
|
2023-12-23 03:02:38 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
::view-transition-old(root),
|
|
|
|
::view-transition-new(root) {
|
|
|
|
animation: none;
|
|
|
|
mix-blend-mode: normal;
|
|
|
|
}
|
|
|
|
|
|
|
|
::view-transition-old(root),
|
|
|
|
.dark::view-transition-new(root) {
|
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
::view-transition-new(root),
|
|
|
|
.dark::view-transition-old(root) {
|
|
|
|
z-index: 9999;
|
|
|
|
}
|
|
|
|
|
|
|
|
.VPSwitchAppearance {
|
|
|
|
width: 22px !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.VPSwitchAppearance .check {
|
|
|
|
transform: none !important;
|
|
|
|
}
|
|
|
|
</style>
|