Class: Blacklight::Icons::IconComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Blacklight::Icons::IconComponent
- Defined in:
- app/components/blacklight/icons/icon_component.rb
Overview
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>'
Direct Known Subclasses
Instance Method Summary collapse
-
#call ⇒ Object
rubocop:enable Metrics/ParameterLists.
-
#initialize(svg: nil, tag: :span, name: nil, label: nil, aria_hidden: nil, classes: nil, **options) ⇒ IconComponent
constructor
rubocop:disable Metrics/ParameterLists.
- #name ⇒ Object
Constructor Details
#initialize(svg: nil, tag: :span, name: nil, label: nil, aria_hidden: nil, classes: nil, **options) ⇒ IconComponent
rubocop:disable Metrics/ParameterLists
10 11 12 13 14 15 16 |
# File 'app/components/blacklight/icons/icon_component.rb', line 10 def initialize(svg: nil, tag: :span, name: nil, label: nil, aria_hidden: nil, classes: nil, **) self.svg = svg if svg @classes = Array(classes) + ['blacklight-icons', "blacklight-icons-#{name}"] @name = name @tag = tag @options = .merge(aria: .fetch(:aria, {}).reverse_merge(label: label, hidden: aria_hidden)) end |
Instance Method Details
#call ⇒ Object
rubocop:enable Metrics/ParameterLists
19 20 21 22 23 |
# File 'app/components/blacklight/icons/icon_component.rb', line 19 def call tag.public_send(@tag, svg&.html_safe, # rubocop:disable Rails/OutputSafety class: @classes, **@options) end |
#name ⇒ Object
27 28 29 |
# File 'app/components/blacklight/icons/icon_component.rb', line 27 def name @name ||= self.class.name.demodulize.underscore.sub('_component', '') end |