diff --git a/app/helpers/alchemy/base_helper.rb b/app/helpers/alchemy/base_helper.rb index 85474418ff..4cdbbe43cc 100644 --- a/app/helpers/alchemy/base_helper.rb +++ b/app/helpers/alchemy/base_helper.rb @@ -28,7 +28,7 @@ def warning(message, text = nil) # @return [String] def render_icon(icon_name, options = {}) options = {style: "line", fixed_width: true}.merge(options) - style = options[:style] && "-#{options[:style]}" + style = options[:style] && "-#{ri_style(options[:style])}" classes = [ "icon", "ri-#{ri_icon(icon_name)}#{style}", @@ -134,5 +134,20 @@ def ri_icon(icon_name) icon_name end end + + # Returns the Remix icon style for given style + # + # @param style [String] The style name + # @return [String] The RemixIcon style + def ri_style(style) + case style.to_s + when "solid", "fill" + "fill" + when "line", "regular" + "line" + else + style + end + end end end diff --git a/spec/helpers/alchemy/base_helper_spec.rb b/spec/helpers/alchemy/base_helper_spec.rb index 12f2622be4..2f7a9d43ba 100644 --- a/spec/helpers/alchemy/base_helper_spec.rb +++ b/spec/helpers/alchemy/base_helper_spec.rb @@ -9,7 +9,7 @@ module Alchemy let(:options) { {} } - it "renders a solid remix icon with fixed width and line style" do + it "renders a remix icon with fixed width and line style" do is_expected.to have_css "i.icon.ri-information-line.ri-fw" end @@ -21,6 +21,30 @@ module Alchemy end end + context "with style set to solid" do + let(:options) { {style: "solid"} } + + it "renders a filled remix icon" do + is_expected.to have_css 'i[class*="-fill"]' + end + end + + context "with style set to regular" do + let(:options) { {style: "regular"} } + + it "renders a line remix icon" do + is_expected.to have_css 'i[class*="-line"]' + end + end + + context "with style set to m" do + let(:options) { {style: "m"} } + + it "renders a line remix icon" do + is_expected.to have_css 'i[class*="-m"]' + end + end + context "with fixed_width set to false" do let(:options) { {fixed_width: false} }