Class: Components::IconSprite

Inherits:
Base
  • Object
show all
Defined in:
lib/backpack/components/icon_sprite.rb

Defined Under Namespace

Classes: Icon

Constant Summary collapse

ICON_PATHS =
[
  Rails.root&.join("app/assets/icons"),
  Rails.root&.join("node_modules/lucide-static/icons")
].compact.freeze

Constants included from Backpack::Attributes

Backpack::Attributes::HTMLAttribute, Backpack::Attributes::HTMLAttributes, Backpack::Attributes::MandatoryHTMLAttribute

Instance Method Summary collapse

Methods included from Backpack::Classes

#root_classes

Methods included from Backpack::Identifier

#identifier

Instance Method Details

#render?Boolean



23
24
25
# File 'lib/backpack/components/icon_sprite.rb', line 23

def render?
  defined?(Current) && Current.respond_to?(:icons) && Current.icons.present?
end

#view_templateObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/backpack/components/icon_sprite.rb', line 11

def view_template
  svg(**mix({ class: root_classes }, @attributes, hidden: true)) do |s|
    s.defs do
      Current.icons.sort.map do |key|
        # rubocop:disable Rails/OutputSafety
        raw Icon.new(key).as_svg_symbol
        # rubocop:enable Rails/OutputSafety
      end
    end
  end
end