-
Notifications
You must be signed in to change notification settings - Fork 913
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
Introduce Dark Mode (WIP) #3028
Introduce Dark Mode (WIP) #3028
Conversation
Used Chroma-js with simple inverted luminance: function inv(s) { var c1 = Chroma(s); c2 = c1.set('lch.l', 100 - c1.get('lch.l')); return c2 }
Used Chroma-js with adjusted inverted luminance: function inv(str) { var c = Chroma(str); // sqrt bends the luminance curve to improve light-on-dark contrast c2 = c.set('lch.l', 100 * Math.sqrt((100 - c.get('lch.l')) / 100)); return c2 }
96306f8
to
17874fd
Compare
Instead of creating additional variables and adding |
That was the first thing I tried, @pkrasicki! It doesn’t work because the variable definitions are interpreted at compile time while the media queries need to happen at render time. There’s a different potential approach using CSS variables which may interfere with the 5% of users who can’t see them; the @media query has less support but it also defaults to existing behavior. I’ll apply your suggestion of lightening everything slightly. |
When I start to review this and see "Large diffs are not rendered by default" and parameters.css getting to 150 lines, I don't think that fits my definition of "maybe 10-20 lines of code to set some colour variables, but little more than that." 😄 This approach has a couple of major drawbacks. The first is that you have changed the name of colour variables like The second is that you are having to invent an entire colour scheme from scratch, as can be seen with the talk about black backgrounds and coloured buttons. I'd prefer to offload those design choices elsewhere, if possible. For example, to an existing "bootstrap-dark" colour scheme where someone else has evaluated what the primary button colours should be, or just how different should the greys used in the background vs On a more minor point, I don't like the 'inv' naming since they aren't inverted - I don't think we'll be highlighting danger messages in cyan, for example! You are right to pick out that there are many colours defined in custom.css that need addressing. However, I'd prefer to see them sorted out first in one (or more) separate PRs. For example, by using the bootstrap variables instead of specific RGB values, or even better by refactoring the code to use bootstrap instead of having any custom CSS in the first place. This will at least bring some structure, and reduce the maintenance burden for supporting dark mode later on. As for the exact mechanism for how to support dark mode - I can't assess if this is the best option. But if you need to define Refs twbs/bootstrap#27514 |
Okay, thanks Andy! I don't think there’s a way to implement dark mode in a way that respects browser settings without a minimal amount of |
Maybe detecting system theme is not the right way then? Instead you could have a button to toggle between default and dark mode. It would require a little bit of JavaScript, but you need it anyway to change map colors in Leaflet. Since Bootstrap doesn't have a dark theme, is it possible to not use custom CSS? |
We are not going to have a button to select dark mode... That's just insane. |
For anyone curious, here's how I implemented the insane dark mode slider on https://nsi.guide It's really just a set of css rules that take effect if This implementation respects the user's dark mode preference the first time, then uses whatever is stored in local storage every time after that. |
@bhousel I did the same in https://issviewer.com. Seems like a reasonable alternative to me. |
This PR offers an alternative approach to browser dark mode, noted by @fishcharlie in #2332 and initially implemented by @bezdna in #2532. Before I spend more than a few hours on this, I’m seeking feedback on an approach that accommodates @gravitystorm’s notes on the prior PR:
The alternative implementation here defines
*-color
and*-invcolor
parameters as suggested though they’re somewhat duplicative becausecommon.scss
had a large number of bare color literals. I migrated all of these to the parameters file without attempting to interpret their meaning. To support dynamic color mode switching these are referenced in media queries near the default definition of each class. Example:I’m also interested in help from anyone who’d like to collaborate on this PR to make it suitable for use! Some sample items left to be done are:
.dropdown-menu
is not yet working/help
and/about
Here’s a short video showing how this implementation of dark mode behaves.
darkmode.mov