Class: Blacklight::Icons::LegacyIconComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Blacklight::Icons::LegacyIconComponent
- Defined in:
- app/components/blacklight/icons/legacy_icon_component.rb
Instance Method Summary collapse
- #call ⇒ Object
- #default_icon ⇒ Object
-
#initialize(name:, classes: '', aria_hidden: false, label: true, role: 'img', additional_options: {}) ⇒ LegacyIconComponent
constructor
A new instance of LegacyIconComponent.
- #svg ⇒ Object
Constructor Details
#initialize(name:, classes: '', aria_hidden: false, label: true, role: 'img', additional_options: {}) ⇒ LegacyIconComponent
Returns a new instance of LegacyIconComponent.
6 7 8 9 10 11 |
# File 'app/components/blacklight/icons/legacy_icon_component.rb', line 6 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: ) end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 |
# File 'app/components/blacklight/icons/legacy_icon_component.rb', line 13 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 |
#default_icon ⇒ Object
25 26 27 |
# File 'app/components/blacklight/icons/legacy_icon_component.rb', line 25 def default_icon @icon.icon_label end |
#svg ⇒ Object
19 20 21 22 23 |
# File 'app/components/blacklight/icons/legacy_icon_component.rb', line 19 def svg Rails.cache.fetch([:blacklight_icon_svg, @name]) do @icon.svg if @icon.present? end end |