From: Anton Khorev Date: Sun, 1 Dec 2024 00:54:36 +0000 (+0300) Subject: Set map color scheme depending on user preferences X-Git-Tag: live~95^2~3 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/141a2164239d4602c7ef937262376e5876607d9a?hp=3d79f9fd88ab2784b292c8eafc46070472b2a4c9 Set map color scheme depending on user preferences --- diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 4bedf42b6..d39535417 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -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; } diff --git a/app/views/layouts/site.html.erb b/app/views/layouts/site.html.erb index 6898b6f0b..f02f024a5 100644 --- a/app/views/layouts/site.html.erb +++ b/app/views/layouts/site.html.erb @@ -3,11 +3,12 @@ :dir => dir, :data => { :bs_theme => (preferred_color_scheme(:site) if preferred_color_scheme(:site) != "auto") } do %> <%= render :partial => "layouts/head" %> - + <%= 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) -%> <% end -%> - + <% end %> <% end %>