-
Notifications
You must be signed in to change notification settings - Fork 2
/
header.astro
131 lines (118 loc) · 2.68 KB
/
header.astro
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
---
import Broadcast from "./broadcast.astro";
import LogoSymbol from "./logo-symbol.astro";
---
<header x-data="{ navOpen: false }">
<a class="logo" aria-label="Gå til forsiden" href="/">
<LogoSymbol />
</a>
<Broadcast />
<div class="right-nav" x-init="$el.style.display = 'flex'">
<button
class="menu-button"
aria-expanded="false"
aria-haspopup="true"
@click="navOpen = !navOpen"
:aria-expanded="navOpen.toString()"
>
<svg
width="18"
height="16"
viewBox="0 0 18 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<rect x="1.99316" y="2" width="14" height="2" fill="black"></rect>
<rect x="1.99316" y="7" width="14" height="2" fill="black"></rect>
<rect x="1.99316" y="12" width="14" height="2" fill="black"></rect>
</svg>
Meny
</button>
<nav x-show="navOpen" x-transition @click.outside="navOpen = false">
<a href="/om">Om oss</a>
<a href="/arbeid">Arbeider</a>
<a href="/tjenester">Våre tjenester</a>
<a href="/artikler">Artikler</a>
<a href="/kontakt">Kontakt oss</a>
</nav>
</div>
</header>
<style>
header {
display: flex;
position: relative;
align-items: center;
width: var(--container-width);
margin-inline: auto;
padding: 2rem 0;
gap: 2rem;
}
.right-nav {
display: none; /* Hide until x-init */
flex-grow: 1;
justify-content: flex-end;
}
@media (max-width: 600px) {
header {
gap: 3rem;
flex-wrap: wrap;
}
a.logo {
order: 2;
}
.right-nav {
order: 3;
}
}
a.logo {
display: flex;
flex-direction: column;
justify-content: center;
color: inherit;
}
.menu-button {
font-size: 1rem;
display: flex;
align-items: center;
border: none;
border-radius: var(--border-radius);
padding-block: 0.5rem;
padding-inline: 0.8rem;
color: var(--color-emphasis-text);
background-color: var(--color-emphasis-bg);
gap: 0.25rem;
cursor: pointer;
}
nav {
position: absolute;
z-index: 9999;
top: 100%;
right: 0px;
width: 100%;
background-color: var(--color-app-bg);
opacity: 1;
visibility: visible;
transition: 0.4s cubic-bezier(0.42, 0, 0.34, 1.01);
text-align: right;
display: flex;
flex-direction: column;
padding-bottom: 6rem;
}
nav[hidden] {
opacity: 0;
visibility: hidden;
pointer-events: none;
}
nav a {
display: block;
padding: 0.5rem;
padding-right: 0rem;
text-decoration: none;
font-size: 1.5rem;
}
@media (hover) {
nav a:hover {
color: var(--color-link);
}
}
</style>