Skip to content

Conversation

@theEquinoxDev
Copy link
Contributor

Summary

This PR adds an optional dark/light mode toggle for the webpack-bundle-analyzer UI, addressing Issue #642.

Implementation

-Added a theme toggle button in the interface
-Implemented CSS custom properties for dark/light theme colors
-Stored theme preference using localStorage
-Updated UI components to support both modes

What kind of change does this PR introduce?

Type: Feature addition (new functionality)
Scope: User interface enhancement with theme switching capability

Tests
No tests added in this PR — functionality affects UI/theme only.

Breaking changes
None. Dark mode is optional, defaults to the existing theme.

This PR addresses the exact issue described in #642 by providing a professional dark mode implementation that enhances user experience without disrupting existing functionality. The implementation follows the project's existing patterns and maintains visual consistency across all interface elements.

Screenshots

-Dark Theme
image
-Light Theme
image

Notes
Happy to update styling or toggle placement based on feedback.
Thanks for the opportunity to work on this feature!

Copy link
Member

@valscion valscion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good start, thanks!

Could we default the dark mode value to what the system has decided and then allow the user to configure something else? That is, the initial value would be based on what prefers-color-scheme media query says: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-color-scheme

And once done, let's also add a changelog entry.

Bonus points if you can figure out some way of having a test for this — I don't think we have any UI-level tests so it's also fine to leave testing out of this PR.

client/store.js Outdated
@observable defaultSize;
@observable selectedSize;
@observable showConcatenatedModulesContent = (localStorage.getItem('showConcatenatedModulesContent') === true);
@observable darkMode = (localStorage.getItem('darkMode') === true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The browser can disable access to localStorage in some environments so we should protect against getItem or setItem throwing an error. We can just fail silently and assume that dark mode is unset and thus use the system value as the default.

@theEquinoxDev
Copy link
Contributor Author

Thanks for the review! I'll update the implementation to:
-use prefers-color-scheme as the default
-only apply localStorage if available
-add a changelog entry

will push shortly..

- Fix PR link to point to webpack/webpack-bundle-analyzer
- Add proper GitHub profile attribution @theEquinoxDev
- Follow established changelog format consistency
@theEquinoxDev
Copy link
Contributor Author

Thanks for the feedback. I have updated the implementation to:
-Use the system prefers-color-scheme value as the initial state
-Add a safe fallback for localStorage access
-Insert a changelog entry under the UNRELEASED section

Please let me know if anything else should be adjusted. Thanks for the opportunity.

Copy link
Member

@valscion valscion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I bet people will like this feature. I think this is a great first iteration and if needed, we can iterate on the dark mode CSS later in case there's some a11y issues especially around color contrast.

@valscion valscion merged commit 492929c into webpack:main Dec 9, 2025
5 checks passed
@valscion
Copy link
Member

valscion commented Dec 9, 2025

Released in v5.1.0 ☺️

@valscion valscion mentioned this pull request Dec 9, 2025
@theEquinoxDev
Copy link
Contributor Author

Thanks for the approval and feedback! Really glad the feature has been useful. I'll definitely keep an eye on the dark mode CSS and accessibility improvements and would be happy to iterate further if needed.
Appreciate the opportunity to contribute 😊

@theEquinoxDev theEquinoxDev deleted the dark-mode-toggle branch December 9, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants