From: Andy Allan Date: Wed, 11 Dec 2024 16:53:15 +0000 (+0000) Subject: Merge pull request #5362 from AntonKhorev/color-mode-preference-map X-Git-Tag: live~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/83043d6f1cd85729a3f91e5c73d78a39b8ae7d04?ds=sidebyside;hp=-c Merge pull request #5362 from AntonKhorev/color-mode-preference-map Map color mode preference --- 83043d6f1cd85729a3f91e5c73d78a39b8ae7d04 diff --combined app/assets/stylesheets/common.scss index c5e2d14b1,d39535417..cabdfff49 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@@ -1,5 -1,6 +1,5 @@@ @use "sass:map"; @import "parameters"; -@import "browse"; @import "bootstrap"; @import "rails_bootstrap_forms"; @@@ -216,10 -217,6 +216,10 @@@ body.small-nav .search_forms { display: block; } + + .username { + max-width: unset; + } } #sidebar .search_forms { @@@ -505,11 -502,6 +505,6 @@@ } @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); } @@@ -519,6 -511,23 +514,23 @@@ } } + @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; } @@@ -935,18 -944,13 +947,18 @@@ div.secondary-actions } } -/* Rules for block pages */ +/* Rules for tables with usernames */ +.messages-table .username, #block_list .username { max-width: 20em; } -/* Rules for tabs inside secondary background sections */ +/* Rules for navigation tabs */ + +.nav-tabs .username { + max-width: 20em; +} .bg-body-secondary .nav-tabs { --bs-border-color: var(--bs-secondary-border-subtle); @@@ -969,20 -973,34 +981,20 @@@ img.trace_image /* Rules for map sidebar icons */ -.browse-section { - .node::before, - .way::before, - .relation::before { - display: inline-block; - width: 25px; - margin-left: -25px; - } +.browse-section .browse-element-list { + line-height: 1.25rem; - .node, .way, .relation { - margin-left: 25px; + .browse-icon { + height: 1.25rem; } - .node::before { content: image-url('browse/node.svg'); } - .way::before { content: image-url('browse/way.svg'); } - .relation::before { content: image-url('browse/relation.svg'); } -} - -@each $class, $item in $map-sidebar-icons { - .browse-section #{$class}::before { - content: image-url('browse/#{map.get($item, "filename")}'); + .d-flex > .browse-icon { + height: max(20px, 1.25rem); } - @if map.get($item, "invert") { - @include color-mode(dark) { - .browse-section #{$class}::before { - filter: invert(.8) hue-rotate(180deg); - } + @include color-mode(dark) { + .browse-icon-invertible { + filter: invert(.8) hue-rotate(180deg); } } } diff --combined app/controllers/application_controller.rb index bde7e0287,5bfec4ab6..32b53bad7 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@@ -21,7 -21,7 +21,7 @@@ class ApplicationController < ActionCon def self.allow_thirdparty_images(**options) content_security_policy(options) do |policy| - policy.img_src("*") + policy.img_src("*", :data) end end @@@ -253,7 -253,9 +253,7 @@@ def map_layout policy = request.content_security_policy.clone - policy.child_src(*policy.child_src, "http://127.0.0.1:8111", "https://127.0.0.1:8112") - policy.frame_src(*policy.frame_src, "http://127.0.0.1:8111", "https://127.0.0.1:8112") - policy.connect_src(*policy.connect_src, Settings.nominatim_url, Settings.overpass_url, Settings.fossgis_osrm_url, Settings.graphhopper_url, Settings.fossgis_valhalla_url) + policy.connect_src(*policy.connect_src, "http://127.0.0.1:8111", Settings.nominatim_url, Settings.overpass_url, Settings.fossgis_osrm_url, Settings.graphhopper_url, Settings.fossgis_valhalla_url) policy.form_action(*policy.form_action, "render.openstreetmap.org") policy.style_src(*policy.style_src, :unsafe_inline) @@@ -279,7 -281,15 +279,15 @@@ end end - helper_method :preferred_editor + def preferred_color_scheme(subject) + if current_user + current_user.preferences.find_by(:k => "#{subject}.color_scheme")&.v || "auto" + else + "auto" + end + end + + helper_method :preferred_editor, :preferred_color_scheme def update_totp if Settings.key?(:totp_key) diff --combined config/locales/en.yml index c3a0c5aed,770e8e40a..94fc77247 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@@ -59,7 -59,6 +59,7 @@@ en message: "Message" node: "Node" node_tag: "Node Tag" + note: "Note" old_node: "Old Node" old_node_tag: "Old Node Tag" old_relation: "Old Relation" @@@ -357,7 -356,8 +357,7 @@@ way: "Way" relation: "Relation" containing_relation: - entry_html: "Relation %{relation_name}" - entry_role_html: "Relation %{relation_name} (as %{relation_role})" + entry_role_html: "%{relation_name} (as %{relation_role})" not_found: title: Not Found sorry: "Sorry, %{type} #%{id} could not be found." @@@ -1477,10 -1477,7 +1477,10 @@@ open: Open resolved: Resolved show: - title: "%{status} Issue #%{issue_id}" + title: + open: "Open Issue #%{issue_id}" + ignored: "Ignored Issue #%{issue_id}" + resolved: "Resolved Issue #%{issue_id}" reports: one: "%{count} report" other: "%{count} reports" @@@ -1810,6 -1807,16 +1810,16 @@@ title: My Preferences preferred_editor: Preferred Editor preferred_languages: Preferred Languages + preferred_site_color_scheme: Preferred Website Color Scheme + site_color_schemes: + auto: Auto + light: Light + dark: Dark + preferred_map_color_scheme: Preferred Map Color Scheme + map_color_schemes: + auto: Auto + light: Light + dark: Dark edit_preferences: Edit Preferences edit: title: Edit Preferences @@@ -2547,7 -2554,7 +2557,7 @@@ upload_trace: "Upload a trace" all_traces: "All Traces" my_traces: "My Traces" - traces_from: "Public Traces from %{user}" + traces_from_html: "Public Traces from %{user}" remove_tag_filter: "Remove Tag Filter" destroy: scheduled_for_deletion: "Trace scheduled for deletion" @@@ -2898,15 -2905,6 +2908,15 @@@ years: one: "%{count} year" other: "%{count} years" + short: + ended: "ended" + revoked_html: "revoked by %{name}" + active: "active" + active_unread: "active unread" + expired_unread: "expired unread" + read_html: "read at %{time}" + time_in_future_title: "%{time_absolute}; in %{time_relative}" + time_in_past_title: "%{time_absolute}; %{time_relative}" blocks_on: title: "Blocks on %{name}" heading_html: "List of Blocks on %{name}" @@@ -2925,21 -2923,21 +2935,21 @@@ reason: "Reason for block:" revoker: "Revoker:" block: - not_revoked: "(not revoked)" show: "Show" edit: "Edit" page: display_name: "Blocked User" creator_name: "Creator" reason: "Reason for block" + start: "Start" + end: "End" status: "Status" - revoker_name: "Revoked by" navigation: all_blocks: "All Blocks" blocks_on_me: "Blocks on Me" - blocks_on_user: "Blocks on %{user}" + blocks_on_user_html: "Blocks on %{user}" blocks_by_me: "Blocks by Me" - blocks_by_user: "Blocks by %{user}" + blocks_by_user_html: "Blocks by %{user}" block: "Block #%{id}" new_block: "New Block" user_mutes: