Skip to content

Commit

Permalink
Merge pull request #2683 from tvdeyen/deprecated-icon-style-support
Browse files Browse the repository at this point in the history
Add support for legacy icon styles
  • Loading branch information
tvdeyen authored Jan 11, 2024
2 parents ddb55df + d30b54e commit dc7cc76
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
17 changes: 16 additions & 1 deletion app/helpers/alchemy/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down Expand Up @@ -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
26 changes: 25 additions & 1 deletion spec/helpers/alchemy/base_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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} }

Expand Down

0 comments on commit dc7cc76

Please sign in to comment.