-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathHeader.astro
More file actions
174 lines (155 loc) · 3.56 KB
/
Header.astro
File metadata and controls
174 lines (155 loc) · 3.56 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
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
172
173
174
---
import { links } from "~/data/links";
import Button from "./Button.astro";
import ContentArea from "./ContentArea.astro";
import Logo from "./Logo.astro";
function hrefProps(pathname: string) {
return {
class: Astro.url.pathname === pathname ? "" : "header-link-inactive",
href: pathname,
target: pathname.startsWith("https") ? "_blank" : undefined,
};
}
---
<header>
<ContentArea class="header-content-area-mobile">
<a class="logo" href="/"><Logo year /></a>
<details id="details">
<summary aria-label="Toggle header">≡</summary>
<div class="header-contents-mobile">
<a {...hrefProps("/about")}>About</a>
<a {...hrefProps("/articles")}>Articles</a>
<a {...hrefProps("/cfp")}>CFP</a>
<a {...hrefProps(links.shop)}>Shop</a>
<a {...hrefProps("/travel")}>Travel</a>
<Button
as="a"
class="header-button"
href={links.tickets}
target="_blank"
variant="accent">Get your ticket</Button
>
</div>
</details>
</ContentArea>
<ContentArea class="header-content-area-wide" width="wide">
<a class="logo" href="/"><Logo year /></a>
<div class="header-links">
<a {...hrefProps("/about")}>About</a>
<a {...hrefProps("/articles")}>Articles</a>
<a {...hrefProps("/cfp")}>CFP</a>
<a {...hrefProps(links.shop)}>Shop</a>
<a {...hrefProps("/travel")}>Travel</a>
<Button
as="a"
class="header-button"
href={links.tickets}
target="_blank"
variant="accent">Get your ticket</Button
>
</div>
</ContentArea>
</header>
<script>
const details = document.querySelector(
"details#details",
) as HTMLDetailsElement;
details.addEventListener("click", (event) => {
if ((event.target as Partial<HTMLElement>).tagName === "A") {
details.removeAttribute("open");
}
});
</script>
<style>
header {
border-bottom: 1px solid var(--colorBlue3);
color: var(--colorWhiteIsh);
background: var(--colorForeground);
font-size: var(--fontSizeSmaller);
padding: 1.5rem 0;
width: 100%;
}
.logo {
text-decoration: none;
}
.header-content-area-mobile {
align-items: center;
display: flex;
justify-content: space-between;
position: relative;
}
details {
position: absolute;
top: 0;
right: 0;
left: 0;
z-index: 2;
text-align: right;
}
summary {
display: inline-block;
cursor: pointer;
font-size: 4rem;
list-style: none;
line-height: 0;
padding: 1rem;
position: absolute;
right: 0;
top: 0;
z-index: 2;
}
summary::-webkit-details-marker {
display: none;
}
.header-contents-mobile {
--offsetTop: 4.5rem;
background: var(--colorForeground);
box-shadow: 0 0 1rem var(--colorTextShadow);
display: flex;
flex-direction: column;
font-family: var(--fontFamilyHeading);
font-size: var(--fontSizeLarge);
font-weight: var(--fontWeightSemibold);
font-weight: bold;
gap: 0.5rem;
line-height: 1.5;
margin-top: 0;
min-width: 20rem;
padding: var(--offsetTop) 1rem 1.5rem;
position: absolute;
right: 0;
text-align: right;
width: 50%;
z-index: 1;
}
.header-contents-mobile .header-button {
align-self: end;
margin-top: 0.5rem;
}
.header-content-area-wide {
display: none;
}
.header-links {
display: flex;
align-items: center;
font-weight: var(--fontWeightLight);
gap: clamp(1rem, 1.5vw, 2rem);
}
.header-link-inactive {
text-decoration: none;
}
.header-button {
justify-content: center;
margin-left: 0.35rem;
}
@media (width >= 1017px) {
.header-content-area-mobile {
display: none;
}
.header-content-area-wide {
align-items: center;
display: flex;
justify-content: space-between;
}
}
</style>