Skip to content

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

Open
gitauto-for-dev[bot] wants to merge 1 commit intomainfrom
gitauto-wes/issue-#80-9ca7b572-2976-46d0-9365-046c85754a32
Open

GitAuto: Add a new icon on the top right to switch this entire website between dark mode and light mode#81
gitauto-for-dev[bot] wants to merge 1 commit intomainfrom
gitauto-wes/issue-#80-9ca7b572-2976-46d0-9365-046c85754a32

Conversation

@gitauto-for-dev
Copy link
Copy Markdown
Contributor

Resolves #80

What is the feature

Add a new icon on the top right corner of the website that allows users to switch between dark mode and light mode. This feature will enable users to toggle the entire website's theme according to their preference.

Why we need the feature

Implementing a dark mode/light mode switch enhances user experience by:

  • Accessibility: Caters to users with visual impairments or sensitivities to bright light.
  • User Preference: Allows users to choose a theme that suits their personal preference or environmental lighting conditions.
  • Reduced Eye Strain: Dark mode can reduce eye strain in low-light conditions.
  • Modernization: Aligns the website with current UI/UX trends adopted by many popular websites and applications.

How to implement and why

  1. Design the Theme Switch Icon:

    • Create an intuitive icon (e.g., a sun/moon symbol) that clearly represents the theme toggling functionality.
    • Place the icon on the top right corner for easy accessibility without cluttering the interface.
  2. Develop CSS for Both Themes:

    • Define CSS variables for colors, backgrounds, and other themable elements.
    • Create separate CSS classes or use data attributes to differentiate between dark and light modes.
    • Ensure that all components are styled appropriately for both themes to maintain visual consistency.
  3. Implement Theme Toggling Logic:

    • Use JavaScript to add an event listener to the theme switch icon.
    • On click, toggle the theme by adding/removing a CSS class or changing a data attribute on the <body> tag.
    • Leverage CSS transitions for a smooth theme change effect.
  4. Persist User Preference:

    • Utilize localStorage to save the user's theme preference.
    • On page load, check localStorage and apply the preferred theme automatically.
    • This ensures a consistent experience across sessions.
  5. Update the UI in the pages Directory:

    • Modify the layout templates to include the new theme switch icon.
    • Ensure that all pages import the updated layout with the theme switcher.
  6. Accessibility Considerations:

    • Add aria-labels to the theme switch icon for screen readers.
    • Ensure the icon is keyboard navigable for users who rely on keyboard navigation.
  7. Testing:

    • Test the feature across different browsers and devices to ensure compatibility.
    • Check for any visual issues in both themes and resolve them.

By implementing the feature step by step, we ensure a seamless integration that enhances user experience without disrupting existing functionalities.

About backward compatibility

  • Non-intrusive Enhancement: The addition is an optional feature that users can choose to interact with, leaving the default experience unchanged for those who don't.
  • Default Theme Consistency: Users who do not engage with the theme switcher will continue to experience the website in its default theme.
  • Graceful Degradation: In environments where JavaScript is disabled or unsupported, the website will fall back to the default theme without impacting usability.
  • No Breaking Changes: Existing styles and scripts remain unaffected; the new theme styles are added on top of the current setup.

Maintaining backward compatibility ensures that all users, regardless of their interaction with the new feature, have a consistent and reliable experience.

Test these changes locally

git checkout -b gitauto-wes/issue-#80-9ca7b572-2976-46d0-9365-046c85754a32
git pull origin gitauto-wes/issue-#80-9ca7b572-2976-46d0-9365-046c85754a32

@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 10:02pm

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