WICG / web-preferences-api

The Web Preference API aims to provide a way for sites to override the value for a given user preference (e.g. color-scheme preference) in a way that fully integrates with existing Web APIs.
https://wicg.github.io/web-preferences-api/
Other
41 stars 2 forks source link

precedence with <meta name="color-scheme" ...> #34

Open jasonwilliams opened 2 weeks ago

jasonwilliams commented 2 weeks ago

Should this specification discuss the precedence with the color-scheme meta tag?

I assume the preferences API will override the color scheme tag (as its user driven) but it isn't mentioned in the docs/spec. I don't know if this would require an update to the color-scheme meta tag section?

My assumptions for now is: Web Prefs Override -> color-scheme meta tag -> OS default

lukewarlow commented 2 weeks ago

Off the top of my head I think it works with the meta tag rather than overriding. So you'd say you support both values and then the API can switch which value is chosen. Just like you today say you support both values and the browser picks the correct value based on the UA value (browser > OS).

jasonwilliams commented 2 weeks ago

Sure, that makes sense when you pass both dark light into the meta tag, but what happens when you only pass one?

<meta name="color-scheme" content="light only">
await navigator.preferences.colorScheme.requestOverride("dark")

refresh page

lukewarlow commented 2 weeks ago

Yeah the case with a single value is interesting, and the case with a single value and only is potentially even more interesting. Needs thinking about. I think in all cases the media query would update at least. But potentially the used colour scheme wouldn't?

Similar to https://github.com/WICG/web-preferences-api/issues/14