Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for legacy icon styles #2683

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading