Class: Blacklight::Facets::SelectedValueComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Blacklight::Facets::SelectedValueComponent
- Defined in:
- app/components/blacklight/facets/selected_value_component.rb
Overview
Standard display of a selected facet value (e.g. without a link and with a remove button)
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(label:, href:) ⇒ SelectedValueComponent
constructor
A new instance of SelectedValueComponent.
- #remove_link ⇒ Object
Methods inherited from Component
reset_compiler!, sidecar_files, upstream_sidecar_files
Constructor Details
#initialize(label:, href:) ⇒ SelectedValueComponent
Returns a new instance of SelectedValueComponent.
7 8 9 10 11 |
# File 'app/components/blacklight/facets/selected_value_component.rb', line 7 def initialize(label:, href:) @label = label @href = href super() end |
Instance Attribute Details
#href ⇒ Object (readonly)
Returns the value of attribute href.
13 14 15 |
# File 'app/components/blacklight/facets/selected_value_component.rb', line 13 def href @href end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
13 14 15 |
# File 'app/components/blacklight/facets/selected_value_component.rb', line 13 def label @label end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 |
# File 'app/components/blacklight/facets/selected_value_component.rb', line 15 def call tag.span(class: "facet-label") do tag.span(label, class: "selected") + remove_link end end |
#remove_link ⇒ Object
21 22 23 24 25 26 |
# File 'app/components/blacklight/facets/selected_value_component.rb', line 21 def remove_link link_to(href, class: "remove ps-2", rel: "nofollow") do render(Blacklight::Icons::RemoveComponent.new(aria_hidden: true)) + tag.span(t(:'blacklight.search.facets.selected.remove'), class: 'visually-hidden') end end |