|
| 1 | +--- |
| 2 | +import HeaderLink from "./HeaderLink.astro"; |
| 3 | +import { Icon } from "astro-icon/components"; |
| 4 | +--- |
| 5 | + |
| 6 | +<header class={` |
| 7 | + bg-stone-50 |
| 8 | + dark:bg-stone-900 |
| 9 | + text-stone-900 |
| 10 | + dark:text-stone-50 |
| 11 | + w-full |
| 12 | + font-shortstack |
| 13 | + flex flex-row |
| 14 | + justify-center |
| 15 | + px-8 py-4 lg:py-8`}> |
| 16 | + <div class={` |
| 17 | + w-full |
| 18 | + max-w-6xl |
| 19 | + flex sm:flex-row lg:flex-row md:flex-col |
| 20 | + sm:align-middle |
| 21 | + justify-between items-center |
| 22 | + `}> |
| 23 | + <a href="/" class="no-underline focus:underline md:mb-4 sm:mb-0 lg:mb-0"> |
| 24 | + <h2 class="center text-xl"> |
| 25 | + Snorre.io |
| 26 | + </h2> |
| 27 | + </a> |
| 28 | + |
| 29 | + <!-- Desktop navigation --> |
| 30 | + <nav class="hidden md:flex flex-row flex-wrap justify-center items-center gap-x-6 md:gap-x-8 gap-y-4 font-shortstack text-xl"> |
| 31 | + <HeaderLink href="/blog">Blog</HeaderLink> |
| 32 | + <HeaderLink href="/projects">Projects</HeaderLink> |
| 33 | + <HeaderLink href="/talks">Talks</HeaderLink> |
| 34 | + <HeaderLink href="/beers">Beers</HeaderLink> |
| 35 | + <HeaderLink href="/music">Music</HeaderLink> |
| 36 | + <HeaderLink href="/about">About</HeaderLink> |
| 37 | + <HeaderLink href="/privacy">Privacy</HeaderLink> |
| 38 | + <div class="flex flex-row flex-nowrap gap-8"> |
| 39 | + <button |
| 40 | + id="theme-toggle" |
| 41 | + class="flex items-center mr-4" |
| 42 | + aria-label="Toggle theme"> |
| 43 | + <Icon class="hidden dark:block w-[1em]" name="material-symbols:light-mode" /> |
| 44 | + <Icon class="block dark:hidden w-[1em]" name="material-symbols:dark-mode" /> |
| 45 | + </button> |
| 46 | + <HeaderLink href="https://github.com/snorremd" title="GitHub" target="_blank"><Icon class="-mx-2 w-[1em]" name="fa6-brands:github" /></HeaderLink> |
| 47 | + <HeaderLink href="https://bsky.app/profile/snorre.io" title="Bluesky" target="_blank"><Icon class="-mx-2 w-[1em]" name="fa6-brands:bluesky" /></HeaderLink> |
| 48 | + <HeaderLink href="/rss.xml" title="RSS Feed"><Icon class="-mx-2 w-[1em]" name="fa6-solid:square-rss" /></HeaderLink> |
| 49 | + </div> |
| 50 | + </nav> |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + <!-- Mobile navigation --> |
| 55 | + <div class="md:hidden relative w-fit ml-auto"> |
| 56 | + <button |
| 57 | + id="mobile-nav-toggle" |
| 58 | + popovertarget="mobile-nav" |
| 59 | + class="p-2 hover:bg-stone-200 dark:hover:bg-stone-800 rounded-drawn-sm transition-colors" |
| 60 | + aria-label="Menu"> |
| 61 | + <Icon name="material-symbols:menu" class="w-6 h-6" /> |
| 62 | + </button> |
| 63 | + |
| 64 | + <nav popover id="mobile-nav" |
| 65 | + class={` |
| 66 | + fixed |
| 67 | + top-0 |
| 68 | + !left-auto |
| 69 | + right-4 |
| 70 | + mt-12 |
| 71 | + popover-open:flex |
| 72 | + hidden |
| 73 | + flex-col |
| 74 | + rounded-drawn |
| 75 | + p-8 |
| 76 | + bg-stone-200 |
| 77 | + dark:bg-stone-800 |
| 78 | + text-stone-900 |
| 79 | + dark:text-stone-50 |
| 80 | + border |
| 81 | + border-stone-300 |
| 82 | + dark:border-stone-700 |
| 83 | + shadow-[0_4px_12px_rgba(0,0,0,0.1)] |
| 84 | + dark:shadow-[0_4px_12px_rgba(0,0,0,0.5)] |
| 85 | + gap-y-4 |
| 86 | + font-shortstack |
| 87 | + text-xl |
| 88 | + min-w-[200px] |
| 89 | + max-h-[calc(100vh-5rem)] |
| 90 | + overflow-y-auto |
| 91 | + scrollbar-thin |
| 92 | + scrollbar-track-stone-300 |
| 93 | + dark:scrollbar-track-stone-700 |
| 94 | + scrollbar-thumb-stone-400 |
| 95 | + dark:scrollbar-thumb-stone-600 |
| 96 | + `}> |
| 97 | + <div class="flex justify-between items-center border-b border-stone-300 dark:border-stone-700 pb-4 mb-2"> |
| 98 | + <h3 class="text-xl font-shortstack">Menu</h3> |
| 99 | + <button |
| 100 | + popovertarget="mobile-nav" |
| 101 | + popovertargetaction="hide" |
| 102 | + class="p-2 hover:bg-stone-300 dark:hover:bg-stone-700 rounded-drawn-sm transition-colors" |
| 103 | + aria-label="Close menu"> |
| 104 | + <Icon name="material-symbols:close" class="w-6 h-6" /> |
| 105 | + </button> |
| 106 | + </div> |
| 107 | + <HeaderLink href="/blog">Blog</HeaderLink> |
| 108 | + <HeaderLink href="/projects">Projects</HeaderLink> |
| 109 | + <HeaderLink href="/talks">Talks</HeaderLink> |
| 110 | + <HeaderLink href="/beers">Beers</HeaderLink> |
| 111 | + <HeaderLink href="/music">Music</HeaderLink> |
| 112 | + <HeaderLink href="/about">About</HeaderLink> |
| 113 | + <HeaderLink href="/privacy">Privacy</HeaderLink> |
| 114 | + |
| 115 | + <div class="flex flex-row gap-4 pt-4 mt-2 border-t border-stone-300 dark:border-stone-700"> |
| 116 | + <button |
| 117 | + id="theme-toggle-mobile" |
| 118 | + class="flex items-center" |
| 119 | + aria-label="Toggle theme"> |
| 120 | + <Icon class="hidden dark:block w-[1em]" name="material-symbols:light-mode" /> |
| 121 | + <Icon class="block dark:hidden w-[1em]" name="material-symbols:dark-mode" /> |
| 122 | + </button> |
| 123 | + <HeaderLink href="https://github.com/snorremd" title="GitHub" target="_blank"><Icon class="w-[1em]" name="fa6-brands:github" /></HeaderLink> |
| 124 | + <HeaderLink href="https://bsky.app/profile/snorre.io" title="Bluesky" target="_blank"><Icon class="w-[1em]" name="fa6-brands:bluesky" /></HeaderLink> |
| 125 | + <HeaderLink href="/rss.xml" title="RSS Feed"><Icon class="w-[1em]" name="fa6-solid:square-rss" /></HeaderLink> |
| 126 | + </div> |
| 127 | + </nav> |
| 128 | + </div> |
| 129 | + </div> |
| 130 | +</header> |
| 131 | + |
| 132 | +<script> |
| 133 | + function setupThemeToggle(buttonId: string) { |
| 134 | + const button = document.getElementById(buttonId); |
| 135 | + if (!button) return; |
| 136 | + |
| 137 | + button.addEventListener('click', () => { |
| 138 | + document.documentElement.classList.toggle('dark'); |
| 139 | + const isDark = document.documentElement.classList.contains('dark'); |
| 140 | + localStorage.setItem('theme', isDark ? 'dark' : 'light'); |
| 141 | + }); |
| 142 | + } |
| 143 | + |
| 144 | + // Setup both desktop and mobile theme toggles |
| 145 | + setupThemeToggle('theme-toggle'); |
| 146 | + setupThemeToggle('theme-toggle-mobile'); |
| 147 | +</script> |
0 commit comments