Sha256: 29d5295be1dc28f4b54e12c1c6ca3a144f45db120c16d28e9541ecb6720ad59f

Contents?: true

Size: 1.08 KB

Versions: 28

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Blacklight
  module Icons
    # This is the list icon for the search button.
    # You can override the default svg by setting:
    #   Blacklight::Icons::ListComponent.svg = '<svg>your SVG here</svg>'
    class IconComponent < ::ViewComponent::Base
      # rubocop:disable Metrics/ParameterLists
      def initialize(svg: nil, tag: :span, name: nil, label: nil, aria_hidden: nil, classes: nil, **options)
        self.svg = svg if svg
        @classes = Array(classes) + ['blacklight-icons', "blacklight-icons-#{name}"]
        @name = name
        @tag = tag
        @options = options.merge(aria: options.fetch(:aria, {}).reverse_merge(label: label, hidden: aria_hidden))
      end
      # rubocop:enable Metrics/ParameterLists

      def call
        tag.public_send(@tag, svg&.html_safe, # rubocop:disable Rails/OutputSafety
                        class: @classes,
                        **@options)
      end

      class_attribute :svg

      def name
        @name ||= self.class.name.demodulize.underscore.sub('_component', '')
      end
    end
  end
end

Version data entries

28 entries across 27 versions & 2 rubygems

Version Path
blacklight-7.38.0 app/components/blacklight/icons/icon_component.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/components/blacklight/icons/icon_component.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/app/components/blacklight/icons/icon_component.rb
blacklight-8.3.0 app/components/blacklight/icons/icon_component.rb
blacklight-8.2.2 app/components/blacklight/icons/icon_component.rb
blacklight-8.2.1 app/components/blacklight/icons/icon_component.rb
blacklight-8.2.0 app/components/blacklight/icons/icon_component.rb
blacklight-7.37.0 app/components/blacklight/icons/icon_component.rb
blacklight-7.36.2 app/components/blacklight/icons/icon_component.rb
blacklight-7.36.1 app/components/blacklight/icons/icon_component.rb
blacklight-7.36.0 app/components/blacklight/icons/icon_component.rb
blacklight-7.35.0 app/components/blacklight/icons/icon_component.rb
blacklight-8.1.0 app/components/blacklight/icons/icon_component.rb
blacklight-7.34.0 app/components/blacklight/icons/icon_component.rb
blacklight-8.0.1 app/components/blacklight/icons/icon_component.rb
blacklight-8.0.0 app/components/blacklight/icons/icon_component.rb
blacklight-8.0.0.beta8 app/components/blacklight/icons/icon_component.rb
blacklight-8.0.0.beta7 app/components/blacklight/icons/icon_component.rb
blacklight-8.0.0.beta6 app/components/blacklight/icons/icon_component.rb
blacklight-8.0.0.beta5 app/components/blacklight/icons/icon_component.rb