Skip to content

Commit

Permalink
Add fallback for Polaris icon source (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
remy727 authored Jun 13, 2024
1 parent 8bc37d6 commit 8fa4a02
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/helpers/polaris/view_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,14 @@ module ViewHelper
end

def polaris_icon_source(name)
path = ViewComponents::Engine.root.join("app", "assets", "icons", "polaris", "#{name}.svg")
paths = [
ViewComponents::Engine.root.join("app", "assets", "icons", "polaris", "#{name}.svg"),
Rails.root.join("app", "assets", "icons", "polaris", "#{name}.svg")
]

path = paths.find { |path| File.exist?(path) }
return unless path

file = File.read(path)
doc = Nokogiri::HTML::DocumentFragment.parse(file)
svg = doc.at_css "svg"
Expand Down

0 comments on commit 8fa4a02

Please sign in to comment.