From 71c502f43fdebc4971b92f24a786fe3839eb93c8 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Mon, 21 Jul 2025 12:25:21 +0300 Subject: [PATCH] Move role colors to css --- app/assets/stylesheets/colors.scss | 11 +++++++++++ app/assets/stylesheets/common.scss | 1 + app/assets/stylesheets/print.scss | 3 +++ app/helpers/authorization_helper.rb | 2 +- app/helpers/user_roles_helper.rb | 15 ++++----------- 5 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 app/assets/stylesheets/colors.scss diff --git a/app/assets/stylesheets/colors.scss b/app/assets/stylesheets/colors.scss new file mode 100644 index 000000000..47ae3c2ed --- /dev/null +++ b/app/assets/stylesheets/colors.scss @@ -0,0 +1,11 @@ +.role-icon { + &.administrator { + color: #f69e42; + } + &.moderator { + color: #447eff; + } + &.importer { + color: #38e13a; + } +} diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index ced3ef44a..415564c57 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -2,6 +2,7 @@ @import "parameters"; @import "bootstrap"; @import "rails_bootstrap_forms"; +@import "colors"; /* Styles common to large and small screens */ diff --git a/app/assets/stylesheets/print.scss b/app/assets/stylesheets/print.scss index a58469ff4..54ca11e23 100644 --- a/app/assets/stylesheets/print.scss +++ b/app/assets/stylesheets/print.scss @@ -1,3 +1,6 @@ +@import "parameters"; +@import "colors"; + html { height: 100%; } diff --git a/app/helpers/authorization_helper.rb b/app/helpers/authorization_helper.rb index 3a95d54ea..549e67cb7 100644 --- a/app/helpers/authorization_helper.rb +++ b/app/helpers/authorization_helper.rb @@ -6,7 +6,7 @@ module AuthorizationHelper html << t("oauth.scopes.#{scope}") if Oauth::MODERATOR_SCOPES.include? scope html << " " - html << role_icon_svg_tag("moderator", false, t("oauth.for_roles.moderator"), :class => "align-text-bottom") + html << role_icon_svg_tag("moderator", false, t("oauth.for_roles.moderator"), ["align-text-bottom"]) end safe_join(html) end diff --git a/app/helpers/user_roles_helper.rb b/app/helpers/user_roles_helper.rb index 3845a7ff3..5fd3b16fa 100644 --- a/app/helpers/user_roles_helper.rb +++ b/app/helpers/user_roles_helper.rb @@ -1,18 +1,11 @@ module UserRolesHelper - def role_icon_svg_tag(role, blank, title, **options) - role_colors = { - "administrator" => "#f69e42", - "moderator" => "#447eff", - "importer" => "#38e13a" - } - color = role_colors[role] || "currentColor" - + def role_icon_svg_tag(role, blank, title, classes = []) path_data = "M 10,2 8.125,8 2,8 6.96875,11.71875 5,18 10,14 15,18 13.03125,11.71875 18,8 11.875,8 10,2 z" - tag.svg(:width => 20, :height => 20, **options) do + tag.svg(:width => 20, :height => 20, :class => ["role-icon", role, *classes]) do concat tag.title(title) concat tag.path(:d => path_data, - :fill => blank ? "none" : color, - :stroke => color, + :fill => blank ? "none" : "currentColor", + :stroke => "currentColor", "stroke-width" => blank ? 1.5 : 2, "stroke-linejoin" => "round") end -- 2.39.5