Conversation
|
The side navigation for the |
Thanks @remcohaszing - FLy by comment (meaning I am not giving this a proper review, at least at this time) Sidebar content for Web API configured in https://github.com/mdn/content/blob/main/files/jsondata/GroupData.json - the name of the API is used in a macro at the top of the Web API docs - do a search in docs on any of the other names here to see how it works. FWIW often I wait for the BCD to be accepted before reviewing docs. |
chrisdavidmills
left a comment
There was a problem hiding this comment.
Hi there @remcohaszing, and thank you for this contribution. This is a really good piece of work. I've made quite a few comments, but they are mainly just similar requests on each page, for the same stuff that is missing.
Let me know if you need any help or have questions.
| #### JavaScript | ||
|
|
||
| ```js | ||
| for (const input of document.getElementsByName("color-scheme")) { |
There was a problem hiding this comment.
I'm not sure if this code is quite right. I did a bit of testing, and it was giving me a syntax error, so I rewrote it to this:
for (input of document.getElementsByName("color-scheme")) {
input.addEventListener("change", () => {
if (input.value === "system") {
navigator.preferences.colorScheme.clearOverride();
} else {
navigator.preferences.colorScheme.requestOverride(input.value);
}
console.log(navigator.preferences.colorScheme.override);
});
}
When I run this, the override value is always logged as "dark", whichever radio I push.
Also, wouldn't it be nice to extend the example a bit to provide some minimal styles in a media query that sets a light and dark color scheme on the page when the radios are chosen?
Making it into a live example would be cool as well, as the reader can test it live on the page. See our live samples guide for more info (https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Page_structures/Live_samples)
There was a problem hiding this comment.
Yes, a live example would be great! I didn’t know how to make one. Thanks for pointing this out. It’s getting late now, so I’ll do this another time.
There was a problem hiding this comment.
I added a live example. I removed the system option because of w3c/csswg-drafts#13613.
remcohaszing
left a comment
There was a problem hiding this comment.
Thanks for the review! I really appreciate it.
| #### JavaScript | ||
|
|
||
| ```js | ||
| for (const input of document.getElementsByName("color-scheme")) { |
There was a problem hiding this comment.
Yes, a live example would be great! I didn’t know how to make one. Thanks for pointing this out. It’s getting late now, so I’ll do this another time.
Description
This adds content for the
navigator.preferencesproperty and related objects.Motivation
I want to raise more awareness for this awesome upcoming feature.
Additional details
Related issues and pull requests
Relates to mdn/browser-compat-data#29142