1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 22:30:03 -04:00

egui_web: default to light mode unless prefers-color-scheme: dark

This commit is contained in:
Emil Ernerfeldt
2021-06-07 20:56:18 +02:00
parent 44b573f6a6
commit 62f58a3b05
8 changed files with 54 additions and 16 deletions

View File

@@ -92,6 +92,15 @@ pub fn native_pixels_per_point() -> f32 {
}
}
pub fn prefer_dark_mode() -> Option<bool> {
Some(
web_sys::window()?
.match_media("(prefers-color-scheme: dark)")
.ok()??
.matches(),
)
}
pub fn canvas_element(canvas_id: &str) -> Option<web_sys::HtmlCanvasElement> {
use wasm_bindgen::JsCast;
let document = web_sys::window()?.document()?;