Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 36 additions & 16 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
import { Icon } from 'astro-icon/components';
const navLinks = [
{ href: '/projects', label: 'Projects' },
{ href: '/webring', label: 'Webring' },
Expand All @@ -11,21 +12,40 @@ const path = Astro.url.pathname;
<a href="/projects" class="text-lg font-bold tracking-tight">
Carleton Computer Science <span class="text-accent">Showcase</span>
</a>
<nav class="flex gap-5 text-sm">
{
navLinks.map(({ href, label }) => (
<a
href={href}
aria-current={path.startsWith(href) ? 'page' : undefined}
class:list={[
'hover:text-accent transition-colors',
path.startsWith(href) ? 'text-accent' : 'text-muted',
]}
>
{label}
</a>
))
}
</nav>
<div class="grouped flex items-center gap-5">
<nav class="flex gap-5 text-sm">
{
navLinks.map(({ href, label }) => (
<a
href={href}
aria-current={path.startsWith(href) ? 'page' : undefined}
class:list={[
'hover:text-accent transition-colors',
path.startsWith(href) ? 'text-accent' : 'text-muted',
]}
>
{label}
</a>
))
}
</nav>
<button
id="theme-toggle"
type="button"
aria-label="Toggle dark mode"
class="text-muted hover:text-accent inline-flex items-center justify-center transition-colors"
>
<!-- Import Lucide Icons -->
<Icon name="lucide:sun" class="hidden size-5 dark:inline" />
<Icon name="lucide:moon" class="size-5 dark:hidden" />
</button>
</div>
</div>
</header>

<script is:inline>
document.getElementById('theme-toggle')?.addEventListener('click', () => {
const isDark = document.documentElement.classList.toggle('dark');
localStorage.setItem('theme', isDark ? 'dark' : 'light');
});
</script>
10 changes: 10 additions & 0 deletions src/layouts/Base.astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ const {

<html lang="en">
<head>
<!-- Checks whether user set to dark mode or prefers-color-scheme is dark -->
<script is:inline>
const saved = localStorage.getItem('theme');
if (
saved === 'dark' ||
(!saved && matchMedia('(prefers-color-scheme: dark)').matches)
) {
document.documentElement.classList.add('dark');
}
</script>
<meta charset="utf-8" />
<!-- Favicon: add files to public/ then uncomment (favicon ticket)
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
Expand Down
11 changes: 11 additions & 0 deletions src/styles/global.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import 'tailwindcss';
@custom-variant dark (&:where(.dark, .dark *));

/*
* Design tokens (Carleton theme, light mode).
Expand Down Expand Up @@ -29,6 +30,16 @@
--radius-card: 0.75rem;
}

html.dark {
--color-canvas: #1b1b1b; /* Carleton black — page background */
--color-surface: #242526; /* cards, panels — a step lighter than canvas */
--color-ink: #f4f3f1; /* primary text — the light off-white */
--color-muted: #9a9a9a; /* secondary text */
--color-accent: #ff3b3b; /* slightly brightened Carleton red for dark bg */
--color-accent-contrast: #ffffff; /* text/icons on an accent fill */
--color-line: #2c2c2c; /* borders, dividers */
}

@layer base {
html {
background-color: var(--color-canvas);
Expand Down
Loading