GitAuto: Add a new icon on the top right to switch this entire website between dark mode and light mode #86
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
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
Implementing a dark mode enhances user experience by providing an option that is easier on the eyes in low-light conditions. It caters to user preferences, as many users now expect websites to offer theme customization. This feature can increase user engagement and satisfaction by making the website more accessible and comfortable to use at any time of day.
How to implement and why
Step 1: Design the Theme Toggle Icon
Step 2: Implement State Management for Themes
useStatehook or a global state management library like Redux to manage the theme state.Step 3: Create Theme Styles
Step 4: Toggle Theme on Icon Click
onClickevent handler to the icon that toggles the theme state between 'light' and 'dark'.Step 5: Apply Themes to the Application
<body>or a top-level<div>).Step 6: Persist User Preference
localStorageto save the selected theme.localStorageand set the theme accordingly.Step 7: Test Across All Pages
Step 8: Accessibility Considerations
aria-labelattributes to the toggle icon for screen readers.Step 9: Update Documentation
About backward compatibility
This feature is backward compatible because it doesn't interfere with existing functionalities. The default theme will remain as light mode, ensuring that users who do not interact with the theme switch will experience the website as before. All new theme-related code will be additive and will not break or alter existing components or pages.
Test these changes locally