Class: Blacklight::ConstraintLayoutComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/blacklight/constraint_layout_component.rb

Direct Known Subclasses

SearchHistoryConstraintLayoutComponent

Instance Method Summary collapse

Methods inherited from Component

reset_compiler!, sidecar_files, upstream_sidecar_files

Constructor Details

#initialize(value:, label: nil, remove_path: nil, classes: nil, search_state: nil) ⇒ ConstraintLayoutComponent

Returns a new instance of ConstraintLayoutComponent.



5
6
7
8
9
10
11
# File 'app/components/blacklight/constraint_layout_component.rb', line 5

def initialize(value:, label: nil, remove_path: nil, classes: nil, search_state: nil)
  @value = value
  @label = label
  @remove_path = remove_path
  @classes = Array(classes).join(' ')
  @search_state = search_state
end

Instance Method Details

#remove_aria_labelObject



13
14
15
16
17
18
19
# File 'app/components/blacklight/constraint_layout_component.rb', line 13

def remove_aria_label
  if @label.blank?
    t('blacklight.search.filters.remove.value', value: @value)
  else
    t('blacklight.search.filters.remove.label_value', label: @label, value: @value)
  end
end

#remove_buttonObject



25
26
27
28
29
30
31
32
# File 'app/components/blacklight/constraint_layout_component.rb', line 25

def remove_button
  return unless @remove_path

  link_to(@remove_path, class: 'btn btn-outline-secondary remove') do
    render(Blacklight::Icons::RemoveComponent.new(aria_hidden: true)) +
      tag.span(remove_aria_label, class: "visually-hidden")
  end
end

#render?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/components/blacklight/constraint_layout_component.rb', line 21

def render?
  @value.present?
end