-
Notifications
You must be signed in to change notification settings - Fork 1
Add dark mode #7 #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add dark mode #7 #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 --> | ||
| <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> | ||
| 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 */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). | ||
|
|
@@ -29,6 +30,17 @@ | |
| --radius-card: 0.75rem; | ||
| } | ||
|
|
||
| /* Dark Mode, may need to adjust as see fit */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
||
There was a problem hiding this comment.
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