Sha256: 3d78ac5713c70d1e20f6d75b4178193d0ae5a5e79baa6b7ba639e9757d869966

Contents?: true

Size: 741 Bytes

Versions: 3

Compression:

Stored size: 741 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  module Document
    # Render a bookmark widget to bookmark / unbookmark a document
    class BookmarkComponent < ::ViewComponent::Base
      # @param [Blacklight::Document] document
      # @param [Boolean] checked
      # @param [Object] bookmark_path the rails route to use for bookmarks
      def initialize(document:, checked: nil, bookmark_path: nil)
        @document = document
        @checked = checked
        @bookmark_path = bookmark_path
      end

      def bookmarked?
        return @checked unless @checked.nil?

        helpers.bookmarked? @document
      end

      def bookmark_path
        @bookmark_path || helpers.bookmark_path(@document)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-7.24.0 app/components/blacklight/document/bookmark_component.rb
blacklight-7.23.0.1 app/components/blacklight/document/bookmark_component.rb
blacklight-7.23.0 app/components/blacklight/document/bookmark_component.rb