Class: Geoblacklight::IconFacetItemComponent

Inherits:
Blacklight::FacetItemComponent
  • Object
show all
Defined in:
app/components/geoblacklight/icon_facet_item_component.rb

Overview

Display facet values with a decorative icon

Examples:

Usage in the blacklight configuration:

config.add_facet_field 'provider_facet', [...], item_component: Geoblacklight::IconFacetItemComponent

Instance Method Summary collapse

Constructor Details

#initialize(facet_item:) ⇒ IconFacetItemComponent

Returns a new instance of IconFacetItemComponent.



10
11
12
13
14
15
# File 'app/components/geoblacklight/icon_facet_item_component.rb', line 10

def initialize(facet_item:, **)
  super

  # store a copy of the original label value
  @undecorated_label = @label
end

Instance Method Details

#before_renderObject



17
18
19
20
21
22
23
# File 'app/components/geoblacklight/icon_facet_item_component.rb', line 17

def before_render
  # replace the original label with an icon-decorated version; this has to be done in
  # #before_render or #render so we have access to the icon helpers.
  @label = decorated_label

  super
end