7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/helpers/view_component/icon_component.rb', line 7
def icon(icon_name, css: nil, span_css: nil, stroke_width: nil)
file = Rails.cache.fetch("neo_components:icon:#{icon_name}") do
ICONS_PATH.join("#{icon_name}.svg").read
end
svg = Nokogiri::HTML::DocumentFragment.parse(file).at_css('svg')
svg['class'] = css
if stroke_width.present?
svg['stroke-width'] = stroke_width
elsif svg['stroke-width'].blank?
svg['stroke-width'] = '1.5'
end
content_tag(:span, svg.to_html.html_safe, class: "flex justify-center items-center #{span_css}".strip) end
|