Skip to content

GitAuto: Add a new icon on the top right to switch this entire website between dark mode and light mode#84

Open
gitauto-for-dev[bot] wants to merge 1 commit intomainfrom
gitauto-wes/issue-#80-102c5f90-89b3-4d59-a17b-9b66004f880e
Open

GitAuto: Add a new icon on the top right to switch this entire website between dark mode and light mode#84
gitauto-for-dev[bot] wants to merge 1 commit intomainfrom
gitauto-wes/issue-#80-102c5f90-89b3-4d59-a17b-9b66004f880e

Conversation

@gitauto-for-dev
Copy link
Copy Markdown
Contributor

Resolves #80

What is the feature

Add a new icon on the top right of the website that allows users to switch between dark mode and light mode.

Why we need the feature

Introducing a dark mode enhances user experience by giving users the option to choose a theme that is comfortable for them, especially in low-light environments. It can reduce eye strain and make the website more accessible to a wider audience. Offering theme customization can also increase user engagement and satisfaction.

How to implement and why

  1. Design the Theme Toggle Icon:

    • Create an icon that clearly represents the theme switch (e.g., a sun/moon or light bulb symbol).
    • Ensure the icon is intuitive and accessible.
  2. Update the Website Layout:

    • Modify the main layout component (located in pages/_app.js or similar) to include the new icon in the top right corner.
    • Use a consistent placement across all pages for better user experience.
  3. Implement Theme State Management:

    • Use React's useState hook to manage the current theme state (light or dark).
    • Alternatively, use a global state management library if one is already in use.
  4. Create Theme Stylesheets:

    • Define CSS variables for colors and other theming aspects in a central stylesheet.
    • Create separate theme files (e.g., themes/light.css and themes/dark.css) that modify these variables.
  5. Apply Themes Dynamically:

    • On theme change, dynamically load the corresponding theme stylesheet.
    • Apply a theme class to the root element (e.g., <html> or <body>) to scope the styles appropriately.
  6. Persist User Preference:

    • Use localStorage to save the user's theme choice so it persists across sessions.
    • On initial load, check localStorage for an existing theme preference and apply it.
  7. Accessibility Considerations:

    • Ensure that the dark mode meets WCAG contrast requirements.
    • Test with screen readers to confirm that the new feature is accessible.
  8. Update Documentation:

    • Document the new theming system in README.md for future developers.
    • Include instructions on how to add or modify themes.
  9. Testing:

    • Test the theme switch across all pages to ensure consistency.
    • Verify that there are no UI regressions in both themes.

About backward compatibility

This feature is backward compatible. By default, the website will continue to display in light mode unless a user actively switches to dark mode. Existing functionality and layout are not affected. Users who do not interact with the theme toggle will experience the website as before. Additionally, storing preferences in localStorage ensures no impact on server-side logic or data structures.

Test these changes locally

git checkout -b gitauto-wes/issue-#80-102c5f90-89b3-4d59-a17b-9b66004f880e
git pull origin gitauto-wes/issue-#80-102c5f90-89b3-4d59-a17b-9b66004f880e

@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sample-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 13, 2024 11:58pm

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a new icon on the top right to switch this entire website between dark mode and light mode

0 participants