Class: Blacklight::Response::ViewTypeButtonComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Blacklight::Response::ViewTypeButtonComponent
- Defined in:
- app/components/blacklight/response/view_type_button_component.rb
Overview
Render spellcheck results for a search query
Instance Method Summary collapse
- #icon ⇒ Object
-
#initialize(view:, key: nil, selected: false, search_state: nil, classes: 'btn btn-outline-secondary btn-icon') ⇒ ViewTypeButtonComponent
constructor
A new instance of ViewTypeButtonComponent.
- #label ⇒ Object
- #selected? ⇒ Boolean
- #url ⇒ Object
Constructor Details
#initialize(view:, key: nil, selected: false, search_state: nil, classes: 'btn btn-outline-secondary btn-icon') ⇒ ViewTypeButtonComponent
Returns a new instance of ViewTypeButtonComponent.
9 10 11 12 13 14 15 |
# File 'app/components/blacklight/response/view_type_button_component.rb', line 9 def initialize(view:, key: nil, selected: false, search_state: nil, classes: 'btn btn-outline-secondary btn-icon') @view = view @key = key || view.key @selected = selected @classes = classes @search_state = search_state end |
Instance Method Details
#icon ⇒ Object
17 18 19 20 21 22 |
# File 'app/components/blacklight/response/view_type_button_component.rb', line 17 def icon return render(@view.icon.new) if @view.icon.is_a?(Class) return render(@view.icon) if @view.icon.is_a?(ViewComponent::Base) helpers.blacklight_icon(@view.icon || @key) end |
#label ⇒ Object
24 25 26 |
# File 'app/components/blacklight/response/view_type_button_component.rb', line 24 def label @view.display_label end |
#selected? ⇒ Boolean
32 33 34 |
# File 'app/components/blacklight/response/view_type_button_component.rb', line 32 def selected? @selected end |
#url ⇒ Object
28 29 30 |
# File 'app/components/blacklight/response/view_type_button_component.rb', line 28 def url helpers.url_for(@search_state.to_h.merge(view: @key)) end |