-
Notifications
You must be signed in to change notification settings - Fork 122
Dark mode blog post #473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Dark mode blog post #473
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions
11
src/constants/MarkdownFiles/authors/syed-khubayb-ur-rahman.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| name: "Syed Khubayb Ur Rahman" | ||
| slug: "syed-khubayb-ur-rahman" | ||
| title: "Contributor" | ||
| organization: "SugarLabs" | ||
| description: "Contributor at Sugar Labs" | ||
| avatar: "https://avatars.githubusercontent.com/u/193499370?v=4" | ||
|
|
||
| --- | ||
|
|
||
| <!--markdownlint-disable--> |
60 changes: 60 additions & 0 deletions
60
src/constants/MarkdownFiles/posts/2025-10-06-adding-dark-mode-to-sugar-labs.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| --- | ||
| title: "Adding dark mode to the main Sugar Labs website" | ||
| excerpt: "New developer Syed Khubayb Ur Rahman shares how he implemented dark mode, what issues he faced and how he debugged them." | ||
| category: "DEVELOPER NEWS" | ||
| date: "2025-10-04" | ||
| slug: "adding-dark-mode-to-sugar-labs" | ||
| author: "@/constants/MarkdownFiles/authors/syed-khubayb-ur-rahman.md" | ||
| tags: "dark-mode,accessibility,frontend,Sugar Labs" | ||
| image: "assets/Images/dark-mode.webp" | ||
| --- | ||
|
|
||
|
|
||
| <!-- markdownlint-disable --> | ||
|
|
||
|
|
||
| # Adding dark mode to a Sugar Labs Website | ||
|
|
||
|
|
||
| ## Introduction | ||
| Sugar Labs builds free/libre/open-source (FLO) tools that make learning playful and accessible. I recently contributed dark mode to a Sugar Labs web project. This post outlines the problem I encountered, how I debugged and fixed it, and the key lessons I learned so others can ship accessible theming with confidence. | ||
| Repository: [https://github.com/sugarlabs/www-v2](https://github.com/sugarlabs/www-v2) | ||
|
|
||
|
|
||
| ## The Problem | ||
| The main Sugar Labs website originally lacked a dark mode option, which made browsing less comfortable in low-light conditions. | ||
| Without dark mode, the bright interface could cause eye strain and reduce accessibility for users with light sensitivity. | ||
|
|
||
|
|
||
| - **Goal:** Deliver a robust dark mode that respects system preference, including a manual toggle with persistence, and maintaining accessible contrast across the interface. | ||
|
|
||
|
|
||
| Implementing the dark mode required careful planning to ensure consistency and accessibility. I began by auditing the color system, identifying issues with hardcoded values, and setting up a structure that would support scalable theming. The steps below summarize my debugging process and how each challenge was resolved. | ||
|
|
||
|
|
||
| ## Debugging and Solution | ||
| - **Color audit and mapping:** I inventoried all color usages, identified hardcoded values, and grouped them into semantic tokens (background, text, muted, accent, surface). This created a maintainable foundation for theming. | ||
| - **Single source of truth:** I centralized color decisions via tokens instead of scattering values across files and components. This reduced duplication and made changes less error‑prone. | ||
| - **Preference‑aware default:** The implementation respects the user’s system setting via the `prefers-color-scheme` media query when no explicit preference is stored. This provides a sensible baseline experience that aligns with OS‑level accessibility choices. | ||
| - **Manual toggle with persistence:** A simple theme switch allows users to override the system default. The selected theme is persisted (e.g., using `localStorage`) so their preference remains consistent across sessions. | ||
| - **Component‑wide updates:** I refactored buttons, inputs, cards, alerts, focus rings, and states (hover, active, disabled) to use tokens. Each state was validated for contrast in both themes. | ||
| - **Icons and media adjustments:** I standardized icons to adapt to the active theme and introduced subtle borders/surfaces to preserve structure on dark backgrounds. | ||
| - **Accessibility validation:** I checked contrast ratios, improved focus visibility, and tested keyboard navigation and zoom to ensure inclusive design. | ||
| - **Cross‑browser and performance checks:** I verified behavior across major browsers and optimized the switch to be instantaneous by relying on theme variables rather than heavy DOM updates. | ||
|
|
||
|
|
||
| ## Challenges and Takeaways | ||
| - **Third‑party components:** Some libraries hardcoded their colors. Carefully scoped overrides and mapping external variables to our tokens aligned them with the overall theme. | ||
| - **Brand color tuning:** The primary accent required adjustments for dark backgrounds. Preserving hue while tweaking lightness/saturation retained brand identity and improved legibility. | ||
| - **Legacy inline styles:** Inline color rules resisted theming. Moving values into tokens eliminated one‑off overrides and simplified maintenance. | ||
| - **Documentation as leverage:** I documented the token system and theme architecture. Clear guidelines made it easier for future contributors to build consistently. | ||
| - **Accessibility‑first mindset:** Dark mode is not color inversion. Designing for contrast, depth, and hierarchy from the start avoids costly rework later. | ||
|
|
||
|
|
||
| ## Impact and Conclusion | ||
| - **Impact on users:** Reduced eye strain, improved readability, and a cohesive experience especially valuable for users with light sensitivity. | ||
| - **Impact on the project:** A unified token system speeds up future development, theming, and contributor onboarding. | ||
| - **Community value:** The approach respects user preferences, provides control, and centers accessibility principles aligned with Sugar Labs’ mission. | ||
|
|
||
|
|
||
| By sharing my experience, I hope to inspire others to contribute to Sugar Labs and make a positive impact on the community. I started by defining semantic tokens, honoring system preferences, and prioritizing accessibility. Through this process, I was able to deliver a dark mode that feels natural, inclusive, and maintainable. | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.