Sha256: 21206bdae3caf1a56bc9161b1654b2a68785fbd3286cd1a842c5725983f0e3a6

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Blacklight
  module Response
    # Render spellcheck results for a search query
    class ViewTypeButtonComponent < ViewComponent::Base
      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)

        Deprecation.silence(Blacklight::CatalogHelperBehavior) do
          helpers.render_view_type_group_icon(@view.icon || @key)
        end
      end

      def label
        Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
          helpers.view_label(@key)
        end
      end

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

      def selected?
        @selected
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
blacklight-7.38.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/components/blacklight/response/view_type_button_component.rb
blacklight-7.37.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-7.36.2 app/components/blacklight/response/view_type_button_component.rb
blacklight-7.36.1 app/components/blacklight/response/view_type_button_component.rb
blacklight-7.36.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-7.35.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-7.34.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-7.33.1 app/components/blacklight/response/view_type_button_component.rb
blacklight-7.33.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-7.32.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-7.31.0 app/components/blacklight/response/view_type_button_component.rb
blacklight-7.30.0 app/components/blacklight/response/view_type_button_component.rb