Skip to content

Add dark mode toggle feature#592

Open
Vishnu912py wants to merge 1 commit into
firstcontributions:mainfrom
Vishnu912py:main
Open

Add dark mode toggle feature#592
Vishnu912py wants to merge 1 commit 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.

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