eratic / packages / core / src / components / SiteHeader.astro
224 words
 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
---
/**
 * The cross-site header.
 *
 * The four sites are four separate origins, so the nav is absolute URLs rather
 * than routes. `current` gets aria-current and loses its link, which is both an
 * accessibility affordance and the only visual state the nav has.
 */
import { NAV_ORDER, SITES, type SiteKey } from '../config.js';

interface Props {
	current: SiteKey;
}

const { current } = Astro.props;
---

<header class="site-header canvas">
	<div class="site-header__inner">
		<a class="wordmark" href={SITES.home.url} rel="home">eratic</a>

		<nav aria-label="Sections">
			<ul>
				{
					NAV_ORDER.map((key) => (
						<li>
							{key === current ? (
								<span aria-current="page">{SITES[key].label}</span>
							) : (
								<a href={SITES[key].url}>{SITES[key].label}</a>
							)}
						</li>
					))
				}
			</ul>
		</nav>
	</div>
</header>

<style>
	.site-header {
		padding-block: var(--space-m);
	}

	.site-header__inner {
		grid-column: wide;
		display: flex;
		flex-wrap: wrap;
		align-items: baseline;
		justify-content: space-between;
		gap: var(--space-s) var(--space-m);
	}

	.wordmark {
		font-family: var(--font-prose);
		font-size: var(--step-1);
		font-weight: 600;
		letter-spacing: -0.02em;
		color: var(--ink);
		text-decoration: none;
	}

	.wordmark:hover {
		color: var(--accent);
	}

	nav ul {
		display: flex;
		gap: var(--space-m);
		list-style: none;
		padding: 0;
		margin: 0;
	}

	nav :is(a, span) {
		font-family: var(--font-ui);
		font-size: var(--step--1);
		letter-spacing: 0.02em;
		text-decoration: none;
		color: var(--ink-muted);
	}

	nav a:hover {
		color: var(--ink);
	}

	nav [aria-current='page'] {
		color: var(--ink);
		/* The current section is marked with a rule rather than a colour, so it
		   still reads when the accent is overridden by an article theme. */
		box-shadow: 0 1px 0 0 var(--ink);
	}
</style>

static mirror of HEAD · about · clone: git clone https://git.makefuture.ro/eratic.git