-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeader.vue
78 lines (77 loc) · 2.97 KB
/
Header.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
<script setup lang="ts">
import { decode, isBlurhashValid } from 'blurhash'
import { useRouter } from 'vue-router'
import { nickPng } from '../assets/images/blurhash-map.json'
import { isDark, toggleDark } from '../logics'
const image = ref<HTMLImageElement | null>(null)
const isLoaded = ref<boolean>(false)
const isVisible = ref<boolean>(true)
const src = import.meta.env.MODE === 'development' ? '/src' + '/assets/images/nick.png' : '/assets/images/nick.png'
const canvas = ref<HTMLCanvasElement | null>(null)
const dropAbout = ref(false)
const router = useRouter()
const to = (route: string) => {
dropAbout.value = !dropAbout.value
router.push(route)
}
onMounted(() => {
if (isBlurhashValid(JSON.parse(nickPng))) {
const pixels = decode(JSON.parse(nickPng), 32, 32)
const imageData = new ImageData(pixels, 32, 32)
const context = canvas.value && canvas.value.getContext('2d')
context && context.putImageData(imageData, 0, 0)
}
})
</script>
<template>
<nav
class="max-w-4xl px-4 m-auto py-6 text-sm z-50 flex items-center justify-between w-full font-semibold text-nosferatu dark:text-cullen"
>
<router-link to="/" class="flex items-center justify-center h-full flex-shrink-0">
<div class="relative">
<img
class="absolute z-20 !transition-opacity !duration-500 !rounded-full w-12 h-12 object-cover object-top ring ring-4 ring-offset-back ring-offset-4 ring-secondary"
:src="src"
/>
<div
class="relative h-12 w-12 "
>
<canvas
ref="canvas"
class="absolute top-0 left-0 right-0 bottom-0 w-full h-full rounded-full"
width="32"
height="32"
/>
</div>
</div>
</router-link>
<div class="flex space-x-6 items-center lg:text-lg text-sm">
<router-link to="/about" class="hover:text-secondary transition-colors duration-150">
<p class="hidden lg:inline-flex">
About
</p>
<noto:octopus class="lg:hidden inline-flex" />
</router-link>
<router-link to="/posts" class="hover:text-secondary transition-colors duration-150">
<p class="hidden lg:inline-flex">
Posts
</p>
<noto:rolled-up-newspaper class="lg:hidden inline-flex" />
</router-link>
<router-link to="/projects" class="hover:text-secondary transition-colors duration-150">
<p class="hidden lg:inline-flex">
Projects
</p>
<noto:laptop class="lg:hidden inline-flex" />
</router-link>
<a href="https://resume.nickgraffis.me" target="_blank" class="hover:text-secondary transition-colors duration-150">
<p class="hidden lg:inline-flex">Resume</p>
<p class="lg:hidden inline-flex">CV</p>
</a>
<a class="cursor-pointer lg:text-xl !text-base hover:text-secondary transition-colors duration-150" @click="toggleDark">
<il:moon v-if="isDark" />
<icon-park-outline:sun-one v-else />
</a>
</div>
</nav>
</template>