UNPKG

vuepress-theme-hope

Version:

A light vuepress theme with tons of features

55 lines 1.91 kB
import { useScrollLock } from "@vueuse/core"; import { Transition, defineComponent, h, onMounted, onUnmounted, shallowRef, watch, } from "vue"; import { onContentUpdated } from "vuepress/client"; import { useWindowSize } from "@theme-hope/composables/index"; import NavScreenLinks from "@theme-hope/modules/navbar/components/NavScreenLinks"; import OutlookSettings from "@theme-hope/modules/outlook/components/OutlookSettings"; import "@vuepress/helper/transition/fade-in-down.css"; import "../styles/nav-screen.scss"; export default defineComponent({ name: "NavScreen", props: { /** * Whether to show the screen * * 是否显示 */ show: Boolean, }, slots: Object, setup(props, { slots }) { const { isMobile } = useWindowSize(); const body = shallowRef(); const isLocked = useScrollLock(body); onContentUpdated(() => { isLocked.value = false; }); watch(isMobile, (value) => { if (!value && props.show) isLocked.value = false; }); onMounted(() => { body.value = document.body; }); onUnmounted(() => { isLocked.value = false; }); return () => h(Transition, { name: "fade-in-down", onEnter: () => { isLocked.value = true; }, onAfterLeave: () => { isLocked.value = false; }, }, () => props.show ? h("div", { id: "nav-screen", class: "vp-nav-screen" }, h("div", { class: "vp-nav-screen-container" }, [ slots.before?.(), h(NavScreenLinks), h("div", { class: "vp-outlook-wrapper" }, h(OutlookSettings)), slots.after?.(), ])) : null); }, }); //# sourceMappingURL=NavScreen.js.map