Sha256: 823a75c84ce84485f295c2b7e283d7b292acdaaaefab5ffd6612c65c2421ce0e

Contents?: true

Size: 972 Bytes

Versions: 17

Compression:

Stored size: 972 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  module Response
    # Render spellcheck results for a search query
    class ViewTypeButtonComponent < Blacklight::Component
      with_collection_parameter :view
      # @param [Blacklight::Configuration::View] view
      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

      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

      def label
        @view.display_label
      end

      def url
        helpers.url_for(@search_state.to_h.merge(view: @key))
      end

      def selected?
        @selected
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
blacklight-8.6.1 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.6.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.5.1 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.5.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.4.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/app/components/blacklight/response/view_type_button_component.rb
blacklight-8.3.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.2.2 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.2.1 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.2.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.1.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.0.1 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.0.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.0.0.beta8 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.0.0.beta7 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.0.0.beta6 app/components/blacklight/response/view_type_button_component.rb
blacklight-8.0.0.beta5 app/components/blacklight/response/view_type_button_component.rb