Skip to content

Commit

Permalink
Merge pull request #616 from lookbook-hq/lucide_sprite
Browse files Browse the repository at this point in the history
Use the Lucide sprite instead of injecting individual SVGs onto the page
  • Loading branch information
allmarkedup authored May 21, 2024
2 parents 296470b + 8b4c375 commit ad1ba3b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
6 changes: 4 additions & 2 deletions app/components/lookbook/icon/component.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= render_component_tag :i, style: "height: #{size_rems}; width: #{size_rems}; #{@html_attrs[:style]}", class: "icon-stroke-#{stroke}" do %>
<%= svg %>
<% end %>
<svg>
<use href="/lookbook-assets/img/lucide-sprite.svg#<%= @icon_name %>"></use>
</svg>
<% end %>
16 changes: 0 additions & 16 deletions app/components/lookbook/icon/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,5 @@ def initialize(name:, size: 4, stroke: 2, **html_attrs)
def size_rems
"#{@size * 0.25}rem"
end

def svg
ICON_CACHE[@icon_name] ||= read_svg
end

def read_svg
File.read(svg_path).html_safe
rescue
if Rails.env.development? || Rails.env.test?
raise "`#{@icon_name}` is not a valid icon name"
end
end

def svg_path
Lookbook::Engine.root.join("assets/icons/#{@icon_name}.svg")
end
end
end

0 comments on commit ad1ba3b

Please sign in to comment.