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,31 +1,51 @@
---
import { Icon } from 'astro-icon/components';
const navLinks = [
{ href: '/projects', label: 'Projects' },
{ href: '/webring', label: 'Webring' },
];
const path = Astro.url.pathname;
---

<!-- Import Lucide Icons -->

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment may be misplaced slightly? Could go near the import line or where the icons are used

<header class="border-line border-b">
<div class="site-container flex items-center justify-between gap-4 py-4">
<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"
>
<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
12 changes: 12 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 *)); /* May break, unrecognized rule */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment here seems unnecessary, could remove it or change to something like "dark mode rule" - seems to be a valid tailwind rule and the linting/formatting checks don't flag anything weird here


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

/* Dark Mode, may need to adjust as see fit */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start! I do think some of the colors could be slightly different. While looking at the changes, what I notice is the main primary text might feel a bit too bright, and the secondary text and red text may be a little too dim against the dark background.
Also, the gap between the canvas and surface blacks can potentially be a bit wider so they pop more.

I'd try playing around with the hex codes a bit more (let me know if I can clarify my thoughts here more since they may be a bit vague)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment can probably just be "Dark mode token overrides"

html.dark {
--color-canvas: #131313; /* Carleton black — page background */
--color-surface: #1d1d1d; /* 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