1- <script setup lang="ts">
2- import { useFetch } from ' @vueuse/core'
3- import { computed , ref } from ' vue'
4-
5- import Github from ' @/components/icons/Socials/Github.vue'
6- import Twitch from ' @/components/icons/Socials/Twitch.vue'
7- import Valory from ' @/components/icons/Valory.vue'
8- import LanguageSwitcher from ' @/components/ui/LanguageSwitcher.vue'
9- import { Button } from ' @/components/ui/button'
10- import { NAV_DATA } from ' @/data/HeaderNav.data'
11- import router from ' @/router'
12- import { hidden , openLink } from ' @/utils'
13- import { moveTo } from ' @/utils'
14-
15- const repoUrl = ref (' https://api.github.com/repos/ValoryApp/Valory' )
16-
17- const { data : repoData } = useFetch (repoUrl ).get ().json ()
18-
19- const starsCount = computed (() => repoData .value ?.stargazers_count ?? 0 )
20- </script >
21-
221<template >
23- <header class =" sticky top-0 z-10 flex h-20 justify-center bg-black/30 text-sm backdrop-blur-sm" >
24- <div class =" container m-auto flex items-center justify-between" >
2+ <header
3+ :class =" [
4+ 'sticky z-10 m-auto flex h-16 w-fit justify-center rounded-full bg-black/30 px-3 text-sm backdrop-blur-sm transition-all duration-300',
5+ showHeader ? 'top-6' : 'top-[-600px]',
6+ ]"
7+ >
8+ <div class =" container m-auto flex items-center justify-between gap-48" >
9+ <div class =" logo" >
10+ <Valory :size =" 30" />
11+ </div >
2512 <div class =" left" >
2613 <ul v-if =" !hidden" class =" flex items-center justify-between gap-6" >
2714 <li
@@ -34,9 +21,6 @@ const starsCount = computed(() => repoData.value?.stargazers_count ?? 0)
3421 </li >
3522 </ul >
3623 </div >
37- <div class =" logo absolute" :class =" [hidden ? '' : 'left-1/2']" >
38- <Valory :size =" 30" />
39- </div >
4024 <div class =" right flex flex-row items-center gap-2" >
4125 <Button
4226 class =" rounded-full border border-transparent bg-transparent text-white opacity-50 transition hover:border-white/10 hover:bg-white/10 hover:opacity-100"
@@ -54,3 +38,45 @@ const starsCount = computed(() => repoData.value?.stargazers_count ?? 0)
5438 </div >
5539 </header >
5640</template >
41+
42+ <script setup lang="ts">
43+ import { useFetch } from ' @vueuse/core'
44+ import { computed , onMounted , onUnmounted , ref } from ' vue'
45+
46+ import Github from ' @/components/icons/Socials/Github.vue'
47+ import Twitch from ' @/components/icons/Socials/Twitch.vue'
48+ import Valory from ' @/components/icons/Valory.vue'
49+ import LanguageSwitcher from ' @/components/ui/LanguageSwitcher.vue'
50+ import { Button } from ' @/components/ui/button'
51+ import { NAV_DATA } from ' @/data/HeaderNav.data'
52+ import router from ' @/router'
53+ import { hidden , openLink } from ' @/utils'
54+ import { moveTo } from ' @/utils'
55+
56+ const repoUrl = ref (' https://api.github.com/repos/ValoryApp/Valory' )
57+
58+ const { data : repoData } = useFetch (repoUrl ).get ().json ()
59+
60+ const starsCount = computed (() => repoData .value ?.stargazers_count ?? 0 )
61+
62+ const showHeader = ref (true )
63+ let lastScrollPosition = 0
64+
65+ const handleScroll = () => {
66+ const currentScrollPosition = window .scrollY
67+ if (currentScrollPosition > lastScrollPosition ) {
68+ showHeader .value = false
69+ } else {
70+ showHeader .value = true
71+ }
72+ lastScrollPosition = currentScrollPosition
73+ }
74+
75+ onMounted (() => {
76+ window .addEventListener (' scroll' , handleScroll )
77+ })
78+
79+ onUnmounted (() => {
80+ window .removeEventListener (' scroll' , handleScroll )
81+ })
82+ </script >
0 commit comments