Skip to content

Add dark mode toggle feature#592

Open
Vishnu912py wants to merge 5 commits into
firstcontributions:mainfrom
Vishnu912py:main
Open

Add dark mode toggle feature#592
Vishnu912py wants to merge 5 commits into
firstcontributions:mainfrom
Vishnu912py:main

Conversation

@Vishnu912py
Copy link
Copy Markdown

Pull Request Description: Add Dark Mode Toggle Feature

Feature Summary

Added a comprehensive dark mode toggle feature to enhance user experience with theme switching capabilities.

Key Features Added:

  • 🌙 Dark Mode Toggle Button: Sun/moon icon button in the top-right navbar for instant theme switching
  • 🎨 Complete Theme Support: All components (navbar, cards, inputs, buttons, text) now support both light and dark themes
  • 💾 Persistent Preferences: User's theme choice is saved in localStorage and persists across sessions
  • 🖥️ System Preference Detection: Automatically detects and respects user's OS dark mode setting by default
  • ✨ Smooth Transitions: Elegant CSS transitions between light and dark themes
  • 📱 Responsive Design: Toggle works seamlessly on all screen sizes

Technical Implementation:

  • New Component: DarkModeToggle.astro with interactive JavaScript for theme switching
  • CSS Custom Properties: Added --bg-primary, --text-primary, etc. for theme variables
  • Global Theme Classes: Uses html.dark class for theme switching
  • Component Updates: Modified 8 components to support theme-aware styling

User Experience:

  • Click the sun icon (☀️) to switch to dark mode
  • Click the moon icon (🌙) to switch back to light mode
  • Theme preference is remembered across browser sessions
  • Smooth color transitions provide polished user experience

Files Modified:

  • src/components/DarkModeToggle.astro (new)
  • src/layouts/Layout.astro
  • src/components/Navbar.astro
  • src/components/App.astro
  • src/components/ProjectCard.astro
  • src/components/ProjectList.astro
  • src/components/SocialShare.astro
  • src/components/IssueList.astro

This feature significantly improves accessibility and user comfort, especially for users who prefer dark themes or work in low-light environments. 🎯

demo.1.mp4

- Add DarkModeToggle component with sun/moon icons
- Update all components to support light/dark themes
- Add CSS custom properties for theme switching
- Implement persistent theme preference storage
- Add smooth transitions between themes
@Sean-Kenneth-Doherty
Copy link
Copy Markdown

I tested this branch locally. The toggle does render in the built page and GITHUB_TOKEN=$(gh auth token) pnpm build exits successfully, but Vite/esbuild emits CSS syntax warnings during the build. There are also source-level issues that should be fixed before review/merge:

  • git diff --check main...HEAD fails on trailing whitespace in src/components/DarkModeToggle.astro, src/components/Navbar.astro, and src/layouts/Layout.astro.
  • Generated .astro/* files are included in the PR diff and should be removed/restored from the branch.
  • src/components/IssueList.astro contains corrupted CSS: box-shavar(--text-primary);, background: rgba(0, 0, 0, 0.1)er;, backgrovar(--text-secondary);, and color: var(--text-primary)t {. These are the exact warnings the build reports, and they will break issue-card styling.

So the feature direction matches #494, but this needs a cleanup pass before it is safe to merge.

@Sean-Kenneth-Doherty
Copy link
Copy Markdown

Thanks for the cleanup pass. I rechecked the current PR head (f1395f03a37d1e760edf345d7e1fecdf3933af6f) and some of the earlier issues are improved: GITHUB_TOKEN=$(gh auth token) pnpm build now succeeds without the previous malformed CSS text warnings, and the exact box-shavar / backgrovar strings are gone.

There are still blockers before this is safe to merge:

  • git diff --check origin/main...HEAD still fails on trailing whitespace in src/components/DarkModeToggle.astro, src/components/Navbar.astro, and src/layouts/Layout.astro.
  • The PR still includes generated .astro/* and dist/* deletions. That cleanup is already handled separately in [codex] remove generated build artifacts #632, so this theme PR should avoid carrying generated artifact churn.
  • DarkModeToggle.astro computes isDarkMode, but the if (isDarkMode) { } branch is empty, so the page does not add document.documentElement.classList.add('dark') on initial load when localStorage/system preference says dark mode should be active.
  • IssueList.astro still renders the literal issue label class string: class="Issue-Label {issue.priority === ...}". That should use an Astro class expression/template literal, or it will not emit good-first-issue / help-wanted classes correctly.
  • The .Issue-Card:hover rule now appears to contain title text-clamp properties (display: -webkit-box, -webkit-line-clamp, etc.), which looks like the .Issue-Title styling accidentally moved into the hover rule.

So this is closer than before, but it still needs a source-only cleanup pass and a quick generated-HTML/style check after that.

@Sean-Kenneth-Doherty
Copy link
Copy Markdown

Nice cleanup pass. I revalidated the new PR head (bff80c877c9c0f7e1ba78b403e2e953db402f61e) and several previous blockers are fixed now:

  • git diff --check origin/main...HEAD is clean
  • GITHUB_TOKEN=$(gh auth token) pnpm build succeeds, 2 pages
  • the built page includes the dark-mode toggle
  • the initialization script now includes document.documentElement.classList.add('dark')
  • the generated HTML no longer contains the literal Issue-Label {issue.priority...} class string; issue labels render as classes like Issue-Label good-first-issue

The remaining blocker I still see is that the PR diff includes generated .astro/* and dist/* deletions. Those files are already handled separately by #632, so this dark-mode PR should restore/remove that generated artifact churn and stay source-only before merge.

@Vishnu912py
Copy link
Copy Markdown
Author

Vishnu912py commented May 17, 2026 via email

@Sean-Kenneth-Doherty
Copy link
Copy Markdown

Rechecked the latest head 546fc8c. Progress: GITHUB_TOKEN=... pnpm build now succeeds, and the generated-file deletion issue has moved in the right direction.

Two blockers still remain before this is clean to merge:

  • The PR still includes generated output/cache files: .astro/data-store.json, .astro/settings.json, .astro/types.d.ts, and new dist/* files. Those should stay out of this feature PR; [codex] remove generated build artifacts #632 is already handling generated artifact cleanup separately.
  • git diff --check origin/main...HEAD currently fails on trailing whitespace in dist/og-image.svg at lines 12, 15, 20, 25, 30, and 36.

Suggested next step: restore/remove the generated .astro and dist changes from this branch, then keep only the dark-mode source files.

@Sean-Kenneth-Doherty
Copy link
Copy Markdown

Rechecked latest head a4f6d76. Build still completes, but this commit regressed from the previous cleanup and has merge blockers:

  • Generated/cache files are back in the PR diff: .astro/* and dist/* are still included.
  • git diff --check origin/main...HEAD fails on trailing whitespace in dist/og-image.svg plus src/components/DarkModeToggle.astro lines 27 and 31.
  • Vite/esbuild reports CSS syntax warnings during pnpm build: box-shavar(--text-primary), backgrovar(--text-secondary), and color: var(--text-primary)t.
  • The malformed CSS is visible in source too: src/components/IssueList.astro line 224 has box-shavar, line 261 has )er, line 300 has backgrovar, and line 307 starts an invalid color: var(--text-primary)t { block. src/components/ProjectCard.astro line 166 also has an incomplete margin:var(--text-secondary declaration.

Suggested next step: restore/remove .astro and dist from the branch again, then repair the malformed CSS declarations before another build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants