WICG / proposals

A home for well-formed proposed incubations for the web platform. All proposals welcome.
https://wicg.io/
Other
233 stars 16 forks source link

Web Preferences API #117

Closed lukewarlow closed 1 year ago

lukewarlow commented 1 year ago

Web Preferences API

Introduction

The Web Preferences API aims to provide a way for sites to indicate a user preference for a given pre-defined setting (e.g. color-scheme preference) in a way that fully integrates with existing Web APIs.

Read the complete Explainer.

Feedback (Choose One)

I welcome feedback in this thread, but encourage you to file bugs against the Explainer.

lukewarlow commented 1 year ago

I've made a very rough draft of a spec: https://specs.lukewarlow.dev/web-preferences-api/

lukewarlow commented 1 year ago

Idk if I count as a potential implementor? But I'm in the progress of making a start on a prototype in Chromium. Haven't filed an intent to prototype yet but working on it locally. Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/UNfjkjHAPOM

yoavweiss commented 1 year ago

Idk if I count as a potential implementor?

If you're implementing, you're an implementor! :)

lilles commented 1 year ago

I'm generally positive. Unsure if navigator is the right place, and which spec it should live in. Currently looks like all values are MQ-related, but that might change?

Also, I'd have to think through the iframe behavior. The color-scheme behavior for things like iframes and embedded SVGs is somewhat complicated, and I'm unsure off-the-top-of-my-head how that would work with this API. But those details can be fleshed out.

This API would also be useful for devtools, which currently in Chromium-based browsers has a separate protocol for overriding media query values.

yoavweiss commented 1 year ago

Glad to see there's support for this! If you want to move this to WICG, feel free to transfer the repo to me and I can do the rest.

bramus commented 1 year ago

I’m personally very supportive of this proposal as it would allow authors to more easily implement Dark Mode Toggle Buttons without needing to duplicate parts of their CSS nor resort to blocking JS – a problem I’ve written about before, at https://www.bram.us/2022/05/25/dark-mode-toggles-should-be-a-browser-feature/

Very excited.

lukewarlow commented 1 year ago

@yoavweiss I've just requested a transfer to you :)

lukewarlow commented 1 year ago

But those details can be fleshed out.

Yeah absolutely there's a few specifics I'm unsure of atm sub-resources is definitely one of them.

This API would also be useful for devtools, which currently in Chromium-based browsers has a separate protocol for overriding media query values.

In my very rough prototype I decided to keep it so dev tools' override is separate to this site preference but again that's something we can nail down in time.

Thanks for taking a look everyone!

yoavweiss commented 1 year ago

The repo now lives at https://github.com/WICG/web-preferences-api

Happy incubating!!