[csswg-drafts] [media-queries-5] Detect all available color schemes (#3882)

AmeliaBR has just created a new issue for https://github.com/w3c/csswg-drafts:

== [media-queries-5] Detect all available color schemes ==
To really support authors who are trying to handle color schemes correctly, there should be a way to detect the available color schemes for a user agent.

This is particularly important if we allow authors to specifically request color schemes, separate from user preferences (e.g., the `only` keyword, as discussed in #3881).  But it has other uses: for example, if the user setting is `no-preference`, the spec currently allows a website designer to request `dark` over `light` (as discussed in #3850), but it doesn't give the author any way of telling whether that request has been honored.

As @emilio mentioned in https://github.com/w3c/csswg-drafts/issues/3848#issuecomment-485230518, the current forward-compatible definition of [`color-scheme`](https://drafts.csswg.org/css-color-adjust-1/#color-scheme-prop) is contrary to usual CSS practice for handling fallbacks and supports testing. @tabatkins points out that, even without the forward-focused bit, `@supports` tests are useless for `color-scheme`, because recognizing a keyword is not the same as having that color scheme available.  Even if the user agent has a color scheme available, it might not apply to the current medium (e.g., print).

So, I'd suggest an `available-color-scheme` media query to complement [`prefers-color-scheme`](https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme).  It's a media query, not a supports test, because it needs to be assessed specifically for the current media environment.  It could factor in user settings beyond a simple preference: e.g., if the website is in a forced-colors dark mode, the only available color scheme should be `dark`.  Or a future web browser might allow users to explicitly say "never dark mode", so that `dark only` requests cannot be honored.  (Or "never light mode", if the user accepts that it might break some websites.)

Complication: we'd need to define a new way of matching media queries, where the media condition is represented by a list of possible keyword values and any of those keywords is considered a `true` value.


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3882 using your GitHub account

Received on Sunday, 28 April 2019 00:46:50 UTC