-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.vue
90 lines (73 loc) · 2.2 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<template>
<Blob v-if="!isBlog" />
<div id="app" ref="app" class="scroll" :class="{ isBlog }">
<NuxtLayout :name="layout">
<NuxtPage :transition="{ name: transitionName, mode: 'out-in', onEnter: enter }" />
</NuxtLayout>
</div>
</template>
<script setup lang="ts">
import type { LayoutKey } from "./.nuxt/types/layouts.d.ts"
useHead({
htmlAttrs: { lang: "en" },
link: [{ href: "/favicon.png", rel: "icon", type: "image/x-icon" }]
})
// Route Store
const route = useRoute()
const isBlog = computed(() => (route.name as string).includes("blogs-slug"))
const isHub = computed(() => (route.name as string).includes("hub"))
const layout = computed<LayoutKey>(() => isHub.value ? "hub" : "default")
provide("isBlog", isBlog)
provide("isHub", isHub)
// Mouse Store
const mouseCoords = ref<[number, number]>([0, 0])
provide("mouseCoords", mouseCoords)
// User Store
const isLoggedIn = ref(false)
provide("isLoggedIn", isLoggedIn)
const app = ref<HTMLDivElement>()
const transitionName = ref("page")
const enter = () => {
app.value?.scrollTo(0, 0)
}
const verifyMobileMedia = () => {
const isMobile = (
"ontouchstart" in window
&& window.matchMedia("(pointer: coarse)").matches
&& window.matchMedia("only screen and (max-width: 570px)").matches
&& /Android|BlackBerry|IEMobile|iPhone|iPod|Opera Mini|webOS|Windows Phone/i.test(navigator.userAgent)
)
if (isMobile) { transitionName.value = "" }
}
onBeforeMount(() => {
verifyMobileMedia()
isLoggedIn.value = localStorage.isLoggedIn === "true"
window.addEventListener("pointermove", event => {
if (event.pointerType !== "touch") {
mouseCoords.value = [event.clientX, event.clientY]
}
})
})
</script>
<style lang="scss">
@import "./assets/stylesheets/application";
#__nuxt {
height: 100%;
#app {
display: flex;
flex-direction: column;
height: 100%;
overflow-y: scroll;
main {
display: flex;
flex-grow: 1;
margin: 50px auto;
}
@media screen and (min-width: 990px) {
&:not(.isBlog) {
backdrop-filter: blur(150px);
}
}
}
}
</style>