GitAuto: Add a new icon on the top right to switch this entire website between dark mode and light mode #82
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #80
What is the feature
This feature introduces a new icon located at the top right corner of the website that allows users to switch between dark mode and light mode. When a user clicks on the icon, the website's theme will toggle between dark and light modes, providing a personalized viewing experience.
Why we need the feature
Implementing a dark mode enhances user experience by catering to individual preferences and environmental lighting conditions. Dark mode can reduce eye strain in low-light environments and improve battery life on devices with OLED screens. Offering a theme switcher directly on the website empowers users to choose their preferred mode without relying on system settings or browser extensions.
How to implement and why
Design the Toggle Icon: Create an intuitive icon (e.g., a moon/sun symbol) that clearly indicates its function. Place it in the top right corner to ensure visibility and accessibility.
State Management:
useStateor context API) to track the current theme.localStorageto persist it across sessions.Theming Mechanism:
Implement Theme Switch Logic:
Update Global Styles:
pagesdirectory to use the theme variables, ensuring consistency across all pages.Accessibility Considerations:
Testing:
Implementing the feature step by step ensures a robust integration that enhances user satisfaction while maintaining website performance and accessibility standards.
About backward compatibility
The addition of the theme switcher is backward compatible. Users who do not interact with the new icon will experience the website in its default mode, ensuring no disruption to their current experience. Since this feature adds functionality without altering existing components or workflows, it should not affect backward compatibility. Existing styles and pages remain intact, with the theme variables providing an additional layer that enhances but does not interfere with the current design.
Test these changes locally