-
Notifications
You must be signed in to change notification settings - Fork 689
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
[css-color] Add a function to allow authors to specify colors reacting to color-scheme
#7561
Comments
…esktop-theme-reviewers,dao This matches what Linux and macOS do, and that allows the fix for bug 1782623 to work on Windows for unstyled selects. This also simplifies the CSS (though it adds a new system color which is a bit more annoying). I filed w3c/csswg-drafts#7561 to propose adding a more generic way to do this in the future (not just for Firefox). Differential Revision: https://phabricator.services.mozilla.com/D153549
Big fan of the A few questions/remarks:
|
I propose to go for I'd propose to do this for |
lol, But given that we purposely designed color-scheme to be extensible for the future, we should do the same here. (But I think we can optimize too.) I propose the grammar be |
In many cases, authors would want to toggle a single channel value (e.g. lightness) within a color. They can do that by repeating the entire color - but allowing |
We need to either know the value type ahead of time, or lean on var() semantics. So we could do the schemed-color() / schemed-value() distinction that Bramus suggests, with the two behaviors. |
Yeah I didn't want to open this to arbitrary lengths and such because that adds a bunch of new property dependencies that I haven't thought through... Though using var() semantics probably works for that case? |
… colors reacting to color-scheme. r=dshin This implement something like what's proposed in w3c/csswg-drafts#7561, but the simplest version possible, until issues are resolved. This will allow the front-end to experiment with it and use it (and we can update to the standard feature once there's a spec for it). Differential Revision: https://phabricator.services.mozilla.com/D184680
… colors reacting to color-scheme. r=dshin This implement something like what's proposed in w3c/csswg-drafts#7561, but the simplest version possible, until issues are resolved. This will allow the front-end to experiment with it and use it (and we can update to the standard feature once there's a spec for it). Differential Revision: https://phabricator.services.mozilla.com/D184680
… colors reacting to color-scheme. r=dshin This implement something like what's proposed in w3c/csswg-drafts#7561, but the simplest version possible, until issues are resolved. This will allow the front-end to experiment with it and use it (and we can update to the standard feature once there's a spec for it). Differential Revision: https://phabricator.services.mozilla.com/D184680 UltraBlame original commit: 1da6261360f2bc8790de86fe9a3a88372c538c8d
… colors reacting to color-scheme. r=dshin This implement something like what's proposed in w3c/csswg-drafts#7561, but the simplest version possible, until issues are resolved. This will allow the front-end to experiment with it and use it (and we can update to the standard feature once there's a spec for it). Differential Revision: https://phabricator.services.mozilla.com/D184680 UltraBlame original commit: 1da6261360f2bc8790de86fe9a3a88372c538c8d
… colors reacting to color-scheme. r=dshin This implement something like what's proposed in w3c/csswg-drafts#7561, but the simplest version possible, until issues are resolved. This will allow the front-end to experiment with it and use it (and we can update to the standard feature once there's a spec for it). Differential Revision: https://phabricator.services.mozilla.com/D184680 UltraBlame original commit: 1da6261360f2bc8790de86fe9a3a88372c538c8d
Additionally, schemed-value() can do something the media query cannot, because prefers-color-scheme matches the same across the document while schemed-value() respond to the per-element color-scheme: <style>
div { background-color: schemed-value(dark red, light green); }
</style>
<div style="color-scheme:light">Green background</div>
<div style="color-scheme:dark">Red background</div> |
The CSS Working Group just discussed
The full IRC log of that discussion<fantasai> emilio: discussed briefly in F2F<fantasai> emilio: Tab's proposal about having a variable-like thing ... <fantasai> emilio: I'm not sure this is ready for resolution. I added Agenda+ F2F and we didn't remove. <fantasai> TabAtkins: I'm happy to discuss my proposal. Two things to consider <fantasai> TabAtkins: The first and easiest one is, just having a color function that responds to color scheme <fantasai> TabAtkins: this doesn't require anything fancy <fantasai> TabAtkins: Proposed syntax is ... <TabAtkins> color-scheme( <color>#{2} | [ <custom-ident> <color> ]#{2,} ) <fantasai> TabAtkins: You can either provide two colors <fantasai> TabAtkins: or provide color scheme ident and color pairs <fantasai> TabAtkins: This matches behavior of existing function that browsers have access to <fantasai> TabAtkins: I know that Chrome and Firefox have something like a light-dark() function <fantasai> TabAtkins: it's simply a color, goes where colors go, responds to color scheme <fantasai> TabAtkins: other one is if you want to do other stuff, e.g. turn shadows on <fantasai> TabAtkins: and that requires var-like semantics <fantasai> TabAtkins: but simple color one will solve a majority of cases we care about here and be very simple <fantasai> fantasai: If you only spec 2 colors, and we later introduce a new color scheme, what happens? <emilio> fantasai: If you only specify two colors and then we add a third color-scheme, then what? <fantasai> TabAtkins: suggest to default to "light" <fantasai> TabAtkins: same issue applies with the list option <fantasai> TabAtkins: in that case, maybe choose first one. or maybe choose "light" if specified <Rossen_> q? <Rossen_> ack fantasai <emilio> fantasai: one of the nice things about ??? is that it makes very explicit what goes where <emilio> ... like minmax() in grid <emilio> ... so I understand that at some point for more schemes we want to tag individual values <TabAtkins> s/???/chrome's internal function/ <emilio> ... but currently we just have light and dark <emilio> ... I think it's a lot better to have light-dark like chrome has <bramus> q+ <TabAtkins> q+ <emilio> ... at some point in the future that could become effectively syntactic sugar for a more-comprehensive function <emilio> ... but even if we have that we could have a light-dark() since that's the more common thing <Rossen_> ack bramus <fantasai> bramus: I want to support what fantasai said, start with light-dark() and have it be syntactic sugar for color-scheme() or whatever in the future <TabAtkins> I'm fine with `light-dark()` even if we have more schemes in the future, it's still a reasonable name. <fantasai> bramus: Internally Chromium had light-dark-color(), but then changed to light-dark() which allowed using in properties other than colors <Rossen_> ack TabAtkins <fantasai> TabAtkins: I'm fine with light-dark() as a name. That's still fine if/when we do define more color schemes <fantasai> TabAtkins: For having a second function that has var-like semantics, but can do anything ... <Rossen_> q? <fantasai> TabAtkins: makes sense to me, but that should be a separate thing so that we have a well-defined <color> that can be accepted in places that accetp colors <fantasai> +! <fantasai> +1 <fantasai> emilio: Shoudl we resolve on light-dark-color() and potentially extend to more color schemes or value types in the future? <emilio> I'd go just for light-dark() as a name fwiw <emilio> but light-dark-color() wfm <fantasai> Rossen_: Proposed resolution is to add a light-dark() or light-dark-color() color ... extend for other color schemes later <TabAtkins> light-dark-value() for the "anything" one? <fantasai> dholbert: if we do want to add an additional function name, light-dark() sounds like a more generic thing <fantasai> dholbert: so might want to use light-dark-color() for the color-specific thing <fantasai> dholbert: but that's just naming thing <Rossen_> ack fantasai <emilio> fantasai: thought about what dholbert just said, but the color is going to be by far the most commonly used thing <emilio> ... so might make sense to have light-dark() for color and something longer for the value syntax <emilio> dholbert: makes sense <emilio> fantasai: poll on the name? <fantasai> Rossen_: Let's pick one and discuss in the issue. <TabAtkins> (and note proposals to, say, name nth-value() to grab an arbitrary value from the list. "value" as an indicator of arbitrary, var-like behavior is somewhat leaned toward as a pattern.) <TabAtkins> 1) light-dark-color() <fantasai> POLL: 1) light-dark-color 2) light-dark <TabAtkins> 2) light-dark() <fantasai> 2 <emilio> 2 <TabAtkins> 2 <bramus> 1 <miriam> either <dholbert> 2, per fantasai's note on making-the-common-thing-easy <rachelandrew> 2 <oriol> abstain <masonf> 2 <bramus> q+ <fantasai> bramus: What about schemed-color() etc.? Would we then have schemed-color() map to light-dark() and schemed-value() to light-dark-value() ? <fantasai> TabAtkins: more color schemes in the future, but light-dark is just for these schemes <Rossen_> ack bramus <fantasai> bramus: returns a color? <fantasai> TabAtkins: yes. If we want value, we can use light-dark-value() <fantasai> RESOLVED: Add light-dark() fuction that returns a color based on the color scheme. <fantasai> s/fuction/function/ |
This matches what Linux and macOS do, and that allows the fix for bug 1782623 to work on Windows for unstyled selects. This also simplifies the CSS (though it adds a new system color which is a bit more annoying). I filed w3c/csswg-drafts#7561 to propose adding a more generic way to do this in the future (not just for Firefox). Differential Revision: https://phabricator.services.mozilla.com/D153549
This matches what Linux and macOS do, and that allows the fix for bug 1782623 to work on Windows for unstyled selects. This also simplifies the CSS (though it adds a new system color which is a bit more annoying). I filed w3c/csswg-drafts#7561 to propose adding a more generic way to do this in the future (not just for Firefox). Differential Revision: https://phabricator.services.mozilla.com/D153549
This matches what Linux and macOS do, and that allows the fix for bug 1782623 to work on Windows for unstyled selects. This also simplifies the CSS (though it adds a new system color which is a bit more annoying). I filed w3c/csswg-drafts#7561 to propose adding a more generic way to do this in the future (not just for Firefox). Differential Revision: https://phabricator.services.mozilla.com/D153549
This matches what Linux and macOS do, and that allows the fix for bug 1782623 to work on Windows for unstyled selects. This also simplifies the CSS (though it adds a new system color which is a bit more annoying). I filed w3c/csswg-drafts#7561 to propose adding a more generic way to do this in the future (not just for Firefox). Differential Revision: https://phabricator.services.mozilla.com/D153549
This matches what Linux and macOS do, and that allows the fix for bug 1782623 to work on Windows for unstyled selects. This also simplifies the CSS (though it adds a new system color which is a bit more annoying). I filed w3c/csswg-drafts#7561 to propose adding a more generic way to do this in the future (not just for Firefox). Differential Revision: https://phabricator.services.mozilla.com/D153549
This matches what Linux and macOS do, and that allows the fix for bug 1782623 to work on Windows for unstyled selects. This also simplifies the CSS (though it adds a new system color which is a bit more annoying). I filed w3c/csswg-drafts#7561 to propose adding a more generic way to do this in the future (not just for Firefox). Differential Revision: https://phabricator.services.mozilla.com/D153549
This matches what Linux and macOS do, and that allows the fix for bug 1782623 to work on Windows for unstyled selects. This also simplifies the CSS (though it adds a new system color which is a bit more annoying). I filed w3c/csswg-drafts#7561 to propose adding a more generic way to do this in the future (not just for Firefox). Differential Revision: https://phabricator.services.mozilla.com/D153549
This matches what Linux and macOS do, and that allows the fix for bug 1782623 to work on Windows for unstyled selects. This also simplifies the CSS (though it adds a new system color which is a bit more annoying). I filed w3c/csswg-drafts#7561 to propose adding a more generic way to do this in the future (not just for Firefox). Differential Revision: https://phabricator.services.mozilla.com/D153549
Just saw this from @bramus's post, and I suspect that things are already closed / there's no changing things now, but I see this as an approach that doesn't actually solve for the issues people are facing with theming, and does so in a way that will create a trap for them when pursuing proper theming support. As a very simple example, what happens when a site that uses this grows to the point where they need to add a high contrast mode? At that point this will require a refactor. The other element I'm concerned with here is it all but seals the deal that As a simple example, consider if it were implemented this way instead:
With this model, you have something that scales beyond light and dark, but now supports visual accessibility modes such has high contrast/colorblind modes. You could also support multiple brands with this, i.e.
We shouldn't ship single-purpose tools for the browser, but rather ones that scale and we can build upon. |
I think this was mistakingly done so. The end goal is to have something like This is also reflected in the meeting minutes: go for (I’m hereby reopening the issue)
The syntax you propose rhymes with was suggested in the original post. I like the suggestion to have the function accept an arbitrary number of scheme-value pairs. Much handier than needing to nest one Side note: I’ve added an extra section to my post to explicitly mention that |
I've always thought of things like high-contrast as somewhat orthogonal to light/dark, for what is worth. Something can still be light or dark and high-contrast. For the record, I think
FWIW, my understanding is that
As @bramus said, we did have this discussion. Anecdata, but in my experience with the Firefox front-end it's gotten quite a bit of adoption (see uses). Firefox does support all sorts of themes, and that didn't make us not use this. Quite the opposite, it did simplify the theming setup quite a bit, from icons, to link colors, etc... As soon as you have a complex enough theming setup, you need parts of the UI to be light and parts to be dark, and It seems you kinda want a more general theming mechanism than what the I'm happy to hold off shipping |
As part of dealing with this issue: I looked again at the definition of
A consequence of adding @emilio @bramus was the intent to exclude |
The sentiment on social media (X, Mastodon) is generally in favor. Recurring comments I’ve heard are:
These issues seem both unrelated to
I can’t gauge the consequences of doing that, so I’ll leave that decision up to Emilio and one of the color experts here – a certain Chris, I think you know him ;) – to make. |
@svgeesus: |
Aha okay, I see. It is in the right place, then. But yeah I was just discussing with @LeaVerou |
What I proposed to @svgeesus was invert this breakdown:
Then also define a Another advantage of this is that it maintains a coherent definition of |
Yeah it's probably worth defining the concept of "absolute-color" or something in prose. |
… colors reacting to color-scheme. r=dshin This implement something like what's proposed in w3c/csswg-drafts#7561, but the simplest version possible, until issues are resolved. This will allow the front-end to experiment with it and use it (and we can update to the standard feature once there's a spec for it). Differential Revision: https://phabricator.services.mozilla.com/D184680
Some UIs require rendering a light button in some places, but dark in another. It'd be nice if you could switch between these by using
color-scheme
, like you can with native widgets. However, right now there's no way to do this other than exclusively using system colors.Chromium has
-internal-light-dark(<light-color>, <dark-color>)
for this. Howevercolor-scheme
was designed a bit more generically thanlight
/dark
, so maybe we need aschemed-color(<custom-ident> <color>, <fallback-color>)
or so, where the<custom-ident>
is the scheme name, and the<color>
is the color for that scheme. So-internal-light-dark(red, blue)
would becomeschemed-color(light red, blue)
or so.This would allow authors to create widgets that properly react to
color-scheme
.The text was updated successfully, but these errors were encountered: