Sha256: c19e2986260db7014d8c061aa25bf63076771c0be1319fab5f87f12a4c641904

Contents?: true

Size: 916 Bytes

Versions: 10

Compression:

Stored size: 916 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  module Icons
    class LegacyIconComponent < ::ViewComponent::Base
      def initialize(name:, classes: '', aria_hidden: false, label: true, role: 'img', additional_options: {})
        @name = name
        @classes = classes
        @aria_hidden = aria_hidden
        @icon = Blacklight::Icon.new(name, classes: classes, label: label, role: role, additional_options: additional_options)
      end

      def call
        tag.span(svg&.html_safe || default_icon, # rubocop:disable Rails/OutputSafety
                 class: "blacklight-icons blacklight-icon-#{@name} #{@classes}".strip,
                 'aria-hidden': (true if @aria_hidden))
      end

      def svg
        Rails.cache.fetch([:blacklight_icon_svg, @name]) do
          @icon.svg if @icon.present?
        end
      end

      def default_icon
        @icon.icon_label
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
blacklight-8.6.1 app/components/blacklight/icons/legacy_icon_component.rb
blacklight-8.6.0 app/components/blacklight/icons/legacy_icon_component.rb
blacklight-8.5.1 app/components/blacklight/icons/legacy_icon_component.rb
blacklight-8.5.0 app/components/blacklight/icons/legacy_icon_component.rb
blacklight-8.4.0 app/components/blacklight/icons/legacy_icon_component.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/app/components/blacklight/icons/legacy_icon_component.rb
blacklight-8.3.0 app/components/blacklight/icons/legacy_icon_component.rb
blacklight-8.2.2 app/components/blacklight/icons/legacy_icon_component.rb
blacklight-8.2.1 app/components/blacklight/icons/legacy_icon_component.rb
blacklight-8.2.0 app/components/blacklight/icons/legacy_icon_component.rb