g1t/apps/docs/src/components/Header.astro

69 lines1,629 bytesCodeBlame
1---
2// Starlight's header, with the tabs that divide the docs beneath it.
3import Default from '@astrojs/starlight/components/Header.astro';
4
5import { TABS, tabFor } from '../tabs';
6
7const current = tabFor(Astro.locals.starlightRoute.id);
8---
9
10<div class="g1t-header">
11 <div class="g1t-header-top"><Default /></div>
12 <nav class="g1t-tabs" aria-label="Sections">
13 {
14 TABS.map((tab) => (
15 <a href={tab.href} aria-current={tab === current ? 'page' : undefined}>
16 {tab.label}
17 </a>
18 ))
19 }
20 </nav>
21</div>
22
23<style>
24 .g1t-header {
25 display: flex;
26 flex-direction: column;
27 height: 100%;
28 }
29 /* The same bar as the app's: 3.5rem, and a line under it. */
30 .g1t-header-top {
31 box-sizing: border-box;
32 height: 3.5rem;
33 flex-shrink: 0;
34 padding: 0 var(--sl-nav-pad-x);
35 border-bottom: 1px solid var(--g1t-line);
36 }
37 /* On phones the menu button sits at the top row's end: leave it room. */
38 @media (max-width: 49.99rem) {
39 :global([data-has-sidebar]) .g1t-header-top {
40 padding-inline-end: calc(var(--sl-nav-pad-x) + var(--sl-menu-button-size) + var(--sl-nav-gap));
41 }
42 }
43 .g1t-tabs {
44 display: flex;
45 gap: 1.5rem;
46 height: 2.75rem;
47 padding: 0 var(--sl-nav-pad-x);
48 overflow-x: auto;
49 scrollbar-width: none;
50 }
51 .g1t-tabs a {
52 display: flex;
53 align-items: center;
54 border-bottom: 1.5px solid transparent;
55 font-size: 0.875rem;
56 font-weight: 500;
57 white-space: nowrap;
58 color: var(--g1t-muted);
59 text-decoration: none;
60 transition: color 0.15s;
61 }
62 .g1t-tabs a:hover {
63 color: var(--g1t-fg);
64 }
65 .g1t-tabs a[aria-current='page'] {
66 border-color: var(--g1t-fg);
67 color: var(--g1t-fg);
68 }
69</style>