GitAuto: Add a new icon on the top right to switch this entire website between dark mode and light mode #87
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 in the top right corner of the website that allows users to switch between dark mode and light mode themes.
Why we need the feature
Implementing a dark mode toggle enhances user experience by accommodating individual preferences and reducing eye strain in low-light environments. Many users prefer dark mode for its aesthetic and comfort, and providing this option keeps the website competitive and user-friendly. It aligns with modern web design standards where theme customization is expected.
How to implement and why
Step 1: Create a Theme Context
Step 2: Develop the Theme Toggle Component
ThemeToggle.js, within thepagesdirectory or a designated components directory.Step 3: Implement Theme Styles
.dark-modeclass that overrides the default CSS variables with dark mode values.Step 4: Apply Theme Class to the Root Element
.dark-modeclass on the root HTML element or a top-level div.Step 5: Persist User Preference
localStorageto save the user's theme preference so it persists across sessions.localStorageand apply it accordingly.Step 6: Update the Layout
ThemeToggleicon in the top right corner.pagesdirectory.Step 7: Test Across All Pages and Devices
Why these steps
About backward compatibility
The addition of the dark mode toggle is backward compatible:
This approach ensures that we improve the website without disrupting the experience for existing users.
Test these changes locally