From f8292b56dfae14da2af7fe765f97015f1559e0fa Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Wed, 26 Mar 2025 20:45:43 +0000 Subject: [PATCH] Replaces legacy icons in flash notices with SVG icons (#41952). git-svn-id: https://svn.redmine.org/redmine/trunk@23562 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/assets/stylesheets/application.css | 27 +++++++++++++++++++++++--- app/helpers/application_helper.rb | 2 +- app/helpers/icons_helper.rb | 13 +++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 96fbb6f8f..849b5e901 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1194,28 +1194,49 @@ input.autocomplete.ajax-loading { } div.flash {margin-top: 8px;} +div.flash:has(svg) { + padding-left: 10px; +} +div.flash svg.icon-svg { + margin-right: 4px; +} div.flash.error, #errorExplanation { - background: url(/exclamation.png) 8px 50% no-repeat; background-color: #ffe3e3; border-color: #d88; color: #880000; } +div.flash.error:not(:has(svg)), #errorExplanation { + background: url(/exclamation.png) 8px 50% no-repeat #ffe3e3; +} +div.flash.error svg.icon-svg { + stroke: #880000; +} div.flash.notice { - background: url(/true.png) 8px 5px no-repeat; background-color: #dfffdf; border-color: #9fcf9f; color: #005f00; } +div.flash.notice:not(:has(svg)) { + background: url(/true.png) 8px 50% no-repeat #dfffdf; +} +div.flash.notice svg.icon-svg { + stroke: #005f00; +} div.flash.warning, .conflict { - background: url(/warning.png) 8px 5px no-repeat; background-color: #F3EDD1; border-color: #eadbbc; color: #A6750C; text-align: left; } +div.flash.warning:not(:has(svg)) { + background: url(/warning.png) 8px 5px no-repeat #F3EDD1; +} +div.flash.warning svg.icon-svg { + stroke: #A6750C; +} .nodata, .warning { text-align: center; diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 50519c890..7991b9b43 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -518,7 +518,7 @@ module ApplicationHelper def render_flash_messages s = +'' flash.each do |k, v| - s << content_tag('div', v.html_safe, :class => "flash #{k}", :id => "flash_#{k}") + s << content_tag('div', notice_icon(k) + v.html_safe, :class => "flash #{k}", :id => "flash_#{k}") end s.html_safe end diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 473f8f780..bee5c22a8 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -79,6 +79,19 @@ module IconsHelper sprite_icon(icon_name, name, size: 14) end + def notice_icon(type, **options) + icon_name = case type + when 'notice' + 'checked' + when 'warning' + 'warning' + when 'error' + 'warning' + end + + sprite_icon(icon_name, **options) + end + private def svg_sprite_icon(icon_name, size: DEFAULT_ICON_SIZE, sprite: DEFAULT_SPRITE, css_class: nil)