-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainNavigation.vue
More file actions
81 lines (72 loc) · 2.19 KB
/
Copy pathMainNavigation.vue
File metadata and controls
81 lines (72 loc) · 2.19 KB
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
<template>
<nav class="relative z-100" aria-label="site" @focusin="handleFocusIn">
<div
class="hidden nav:block shadow-sm fixed top-0 left-0 right-0 bg-background transition-transform duration-default ease-default"
:class="{
'-translate-y-full': !isVisible,
}"
>
<ContentContainer class="flex justify-between items-center h-nav-height">
<ul
class="hidden nav:flex gap-x-3 xl:gap-x-8 justify-center items-center w-full"
>
<li v-for="(link, index) in links" :key="link?.url ?? index">
<InlineLink
v-if="link?.url"
:href="link.url"
:external="link.external"
:aria-selected="isSelected(link.url)"
class="text-lg text-foreground no-underline px-4 py-2 hover:border-foreground border-2 border-transparent rounded-lg aria-selected:border-foreground"
>
{{ link.text }}
</InlineLink>
</li>
</ul>
</ContentContainer>
</div>
<MobileMenu :links="links" :cta="cta" />
<NuxtLink
v-if="cta?.url"
:to="cta.url"
:external="cta.external ?? false"
:aria-selected="isSelected(cta.url)"
class="hidden nav:block floating-button border-background border-2 text-lg button button-md fixed top-1.5"
>
{{ cta.text }}
</NuxtLink>
</nav>
</template>
<script setup lang="ts">
import { ScrollTrigger } from "gsap/ScrollTrigger";
import { gsap } from "gsap";
import type { LinkFragment } from "~~/shared/types/graphql";
const { links, cta } = defineProps<{
links: (LinkFragment | null)[];
cta: LinkFragment | null;
}>();
const route = useRoute();
const isSelected = (path: string) => {
return route.path === path;
};
const isVisible = shallowRef(true);
onMounted(() => {
gsap.registerPlugin(ScrollTrigger);
ScrollTrigger.create({
start: "top -100",
onUpdate: (self) => {
isVisible.value = self.direction === -1;
},
});
});
const handleFocusIn = () => {
isVisible.value = true;
};
</script>
<style scoped>
.floating-button {
right: max(
var(--spacing-side),
calc((100vw - var(--spacing-max-width)) / 2 + var(--spacing-side))
);
}
</style>