# Description `prefers-color-scheme` is a CSS feature which allows CSS to conditionally set styles based on the user's preference for light or dark mode. MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme Spec: https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme ## Implementation plan - https://github.com/servo/stylo/pull/93 enables this feature in Stylo (which is doing all the hard work for us). - https://github.com/servo/servo/pull/34423 updates Servo to use that version of Stylo (but hardcodes "light mode"). The remaining work is to: - [ ] Add an embedder event for setting the preferred color scheme - [ ] Plumb this through to the layout thread where it should be set on the device (possibly via a "reflow", similar to window size?) - [ ] Connect this to Winit `ThemeChanged` events in `servoshell`. We should also obtain an initial value from winit when creating the window.
Activity
arthmis commentedon Nov 29, 2024
Hi I'm a new contributor and I would like to work on this issue. Is there any context I should know to tackle this issue?
nicoburns commentedon Dec 3, 2024
You can see the value which needs to be set to enable "dark mode" here: https://github.com/servo/servo/pull/34423/files#diff-110381529b2694b44285f15e5eba966a5b50a20720c5dcedd804766e95d834e0R1128
That needs to be connected with the Winit ThemeChanged event which can be hooked into here:
servo/ports/servoshell/desktop/headed_window.rs
Line 399 in ad448da
The winit event needs to generate a (new)
EmbedderEventhttps://github.com/servo/servo/blob/main/components/compositing/windowing.rs#L45 that works similarly to the existingWindowResizeevent (although perhaps passed the new theme inside theEmbedderEvent).arthmis commentedon Dec 3, 2024
thank you for laying that all out! I'll get on it then