]> git.openstreetmap.org Git - rails.git/commitdiff
Set map color scheme depending on user preferences
authorAnton Khorev <tony29@yandex.ru>
Sun, 1 Dec 2024 00:54:36 +0000 (03:54 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sun, 1 Dec 2024 01:58:00 +0000 (04:58 +0300)
app/assets/stylesheets/common.scss
app/views/layouts/site.html.erb

index 4bedf42b6ac2b6571a7b09d27f2bf11973c6d222..d39535417e1d6868c8f2c7b6b3560568d9feac19 100644 (file)
@@ -502,11 +502,6 @@ body.small-nav {
 }
 
 @include color-mode(dark) {
-  .leaflet-tile-container .leaflet-tile,
-  .mapkey-table-entry td:first-child > * {
-    filter: brightness(.8);
-  }
-
   .leaflet-container .leaflet-control-attribution a {
     color: var(--bs-link-color);
   }
@@ -516,6 +511,23 @@ body.small-nav {
   }
 }
 
+@mixin dark-map-color-scheme {
+  .leaflet-tile-container .leaflet-tile,
+  .mapkey-table-entry td:first-child > * {
+    filter: brightness(.8);
+  }
+}
+
+body[data-map-theme="dark"] {
+  @include dark-map-color-scheme;
+}
+
+@include color-mode(dark) {
+  body:not([data-map-theme]) {
+    @include dark-map-color-scheme;
+  }
+}
+
 /* Rules for attribution text under the main map shown on printouts */
 
 .donate-attr { color: darken($green, 10%) !important; }
index 6898b6f0bbff447522f1b7394cc55cfd38d99b5d..f02f024a57a69e84905c76122f1b16ff053e8f20 100644 (file)
@@ -3,11 +3,12 @@
              :dir => dir,
              :data => { :bs_theme => (preferred_color_scheme(:site) if preferred_color_scheme(:site) != "auto") } do %>
   <%= render :partial => "layouts/head" %>
-  <body class="<%= body_class %>">
+  <%= tag.body :class => body_class,
+               :data => { :map_theme => (preferred_color_scheme(:map) if preferred_color_scheme(:map) != "auto") } do %>
     <%= render :partial => "layouts/header" %>
     <%= render :partial => "layouts/content" %>
     <% if defined?(Settings.matomo) -%>
     <noscript><p><img src="<%= request.protocol %><%= Settings.matomo["location"] %>/matomo.php?idsite=<%= Settings.matomo["site"] %>" class="matomo" alt="" /></p></noscript>
     <% end -%>
-  </body>
+  <% end %>
 <% end %>