+ This document is to experiment with dark mode
+ (#551).
+
+
+
+ The author of this document has indicated to UAs it is compatible with
+ dark mode as well as light mode
+ (with a preference for dark mode)
+ using
+ <meta name="color-scheme" content="dark light">,
+ allowing the UA to render this document with an appropriate color scheme.
+
+
+
+ Set the preference for dark mode in your browser/OS settings or dev tools!
+
+
+
diff --git a/styling/media-queries/match-media/prefers-color-scheme/dark.mapml b/styling/media-queries/match-media/prefers-color-scheme/dark.mapml
new file mode 100644
index 0000000..34820a8
--- /dev/null
+++ b/styling/media-queries/match-media/prefers-color-scheme/dark.mapml
@@ -0,0 +1,15 @@
+
+
+ pmtiles - dark theme
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/styling/media-queries/match-media/prefers-color-scheme/darkTheme.js b/styling/media-queries/match-media/prefers-color-scheme/darkTheme.js
new file mode 100644
index 0000000..830e7f5
--- /dev/null
+++ b/styling/media-queries/match-media/prefers-color-scheme/darkTheme.js
@@ -0,0 +1,6 @@
+const pmtilesRules = new Map();
+pmtilesRules.set(
+ 'https://maps4html.org/experiments/vector-tiles/pmtiles/spearfish.pmtiles?theme=dark',
+ { theme: { theme: 'dark' } }
+);
+export { pmtilesRules };
diff --git a/styling/media-queries/match-media/prefers-color-scheme/index.html b/styling/media-queries/match-media/prefers-color-scheme/index.html
new file mode 100644
index 0000000..aae0e02
--- /dev/null
+++ b/styling/media-queries/match-media/prefers-color-scheme/index.html
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+ matchMedia API
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Introduction to Adaptive Color Scheme for mapml-viewer
+
This experiment demonstrates the integration of adaptive color schemes for the mapml-viewer custom element, enabling it to adjust between light and dark modes based on the user’s system preferences. By implementing a color scheme that responds to the OS or browser’s preferred settings, we aim to enhance visual comfort and accessibility across different environments.
+
The page automatically detects and applies the appropriate theme, allowing users to experience the map viewer seamlessly in both light and dark modes. This implementation uses the <meta name="color-scheme" content="dark light"> attribute to signal to the browser the compatibility with both modes, ensuring a responsive and user-friendly experience.
+
How to Emulate OS Preferred Color Scheme in Browsers
+
+
Google Chrome:
+
+
Go to chrome://settings/appearance and toggle the "Theme" to "System default" or "Dark."
+
Alternatively, open DevTools (F12 or right-click > Inspect) > click on the "More Tools" menu (three dots) > "Rendering" > "Emulate CSS prefers-color-scheme" > select "light" or "dark."
+
+
+
Mozilla Firefox:
+
+
Go to about:addons, select "Themes," and set it to "System Theme" for automatic adjustment.
+
In DevTools, go to the "Settings" icon, scroll to the "Developer Tools" section, and under "Preferences," find "Emulate CSS prefers-color-scheme" to choose light or dark mode.
+
+
+
Microsoft Edge:
+
+
Open edge://settings/appearance and set the theme to "System default" or "Dark."
+
In DevTools, go to "More Tools" > "Rendering" and select the preferred color scheme under "Emulate CSS prefers-color-scheme."
+
+
+
+
These settings will allow you to see how the mapml-viewer element adapts to different color schemes in real-time, providing an intuitive user experience that aligns with system preferences.