Class: Blacklight::Facets::SelectedValueComponent

Inherits:
Component
  • Object
show all
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

Instance Method Summary collapse

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

#hrefObject (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

#labelObject (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

#callObject



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


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