This repository was archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAppHeader.vue
171 lines (165 loc) · 5.33 KB
/
AppHeader.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<template>
<nav
class="fixed top-0 z-40 w-full border-b dark:border-gray-800 bg-white dark:bg-gray-900"
:class="{ 'shadow border-transparent': scrolled }"
@click="scrollToTop"
>
<div class="container mx-auto flex-1 px-4 lg:px-8">
<div class="flex items-center justify-between h-16">
<div class="lg:w-1/5 flex items-center pr-4" @click.stop="noop">
<NuxtLink
:to="localePath('/')"
class="flex-shrink-0 flex-1 font-bold text-xl"
:aria-label="`${settings.title} Logo`"
>
<span v-if="!logo">{{ settings.title }}</span>
<img
v-if="logo"
:src="logo.light"
class="h-8 max-w-full light-img"
:alt="settings.title"
/>
<img v-if="logo" :src="logo.dark" class="h-8 max-w-full dark-img" :alt="settings.title" />
</NuxtLink>
</div>
<div v-if="settings.layout !== 'single'" class="flex-1 flex justify-start w-4/6">
<AppSearchAlgolia v-if="settings.algolia" :options="settings.algolia" :settings="settings" />
<AppSearch v-else class="hidden lg:block" />
</div>
<div
class="lg:w-1/5 flex items-center pl-4 lg:pl-8"
:class="{ 'justify-between': lastRelease && settings.layout !== 'single', 'justify-end': !lastRelease || settings.layout === 'single' }"
>
<NuxtLink
v-if="lastRelease"
to="/releases"
class="font-semibold leading-none text-gray-700 dark:text-gray-300 hover:text-primary-500 dark-hover:text-primary-500 text-base mr-4"
exact-active-class="text-primary-500"
>{{ lastRelease.name }}</NuxtLink>
<div class="flex items-center">
<a
v-if="settings.linkedin"
:href="`https://www.linkedin.com/company/${settings.linkedin}/?viewAsMember=true`"
target="_blank"
rel="noopener noreferrer"
title="LinkendIn"
name="LinkendIn"
class="text-gray-700 dark:text-gray-300 hover:text-primary-500 dark-hover:text-primary-500 ml-4"
:class="{
'hidden lg:block': settings.layout !== 'single'
}"
>
<IconLinkendin class="w-5 h-5" />
</a>
<a
v-if="settings.youtube"
:href="`https://www.youtube.com/c/${settings.youtube}`"
target="_blank"
rel="noopener noreferrer"
title="YouTube"
name="YouTube"
class="text-gray-700 dark:text-gray-300 hover:text-primary-500 dark-hover:text-primary-500 ml-4"
:class="{
'hidden lg:block': settings.layout !== 'single'
}"
>
<IconYoutube class="w-5 h-5" />
</a>
<a
v-if="settings.twitter"
:href="`https://twitter.com/${settings.twitter}`"
target="_blank"
rel="noopener noreferrer"
title="Twitter"
name="Twitter"
class="text-gray-700 dark:text-gray-300 hover:text-primary-500 dark-hover:text-primary-500 ml-4"
:class="{
'hidden lg:block': settings.layout !== 'single'
}"
>
<IconTwitter class="w-5 h-5" />
</a>
<a
v-if="settings.github"
:href="githubUrls.repo"
target="_blank"
rel="noopener noreferrer"
title="Github"
name="Github"
class="text-gray-700 dark:text-gray-300 hover:text-primary-500 dark-hover:text-primary-500 ml-4"
:class="{
'hidden lg:block': settings.layout !== 'single'
}"
>
<IconGithub class="w-5 h-5" />
</a>
<button
v-if="settings.layout !== 'single'"
class="lg:hidden p-2 rounded-md text-gray-700 dark:text-gray-300 focus:outline-none -mr-2"
aria-label="Menu"
@click.stop="menu = !menu"
>
<IconX v-if="menu" class="w-5 h-5" />
<IconMenu v-else class="w-5 h-5" />
</button>
</div>
</div>
</div>
</div>
</nav>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
data () {
return {
scrolled: 0
}
},
computed: {
...mapGetters([
'settings',
'githubUrls',
'lastRelease'
]),
menu: {
get () {
return this.$store.state.menu.open
},
set (val) {
this.$store.commit('menu/toggle', val)
}
},
logo () {
if (!this.settings.logo) {
return
}
if (typeof this.settings.logo === 'object') {
return this.settings.logo
}
return {
light: this.settings.logo,
dark: this.settings.logo
}
}
},
beforeMount () {
window.addEventListener('scroll', this.handleScroll)
},
beforeDestroy () {
window.removeEventListener('scroll', this.handleScroll)
},
methods: {
handleScroll () {
this.scrolled = window.scrollY > 0
},
scrollToTop () {
if (window.innerWidth >= 1280) {
return
}
window.scrollTo(0, 0)
},
noop () { }
}
}
</script>