From 9c138c8c69e45088f0351cf2005dadb16045ec33 Mon Sep 17 00:00:00 2001 From: Remy Wang Date: Thu, 13 Jun 2024 14:53:37 +0200 Subject: [PATCH] feat: add fallback for polaris icon source --- app/helpers/polaris/view_helper.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/helpers/polaris/view_helper.rb b/app/helpers/polaris/view_helper.rb index 539df6b1..e77a4a09 100644 --- a/app/helpers/polaris/view_helper.rb +++ b/app/helpers/polaris/view_helper.rb @@ -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"