Skip to content

Commit

Permalink
Add a similar holdings component
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Nov 14, 2024
1 parent 743e80d commit adf22e2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/components/access_panels/similar_holdings_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module AccessPanels
class SimilarHoldingsComponent < ViewComponent::Base
def initialize(document:)
@id = document.id
super()
end

def call
helpers.turbo_frame_tag 'similar_holdings', src: "https://semantic-search-demo.stanford.edu/similar/#{@id}"
end
end
end
1 change: 1 addition & 0 deletions app/views/catalog/record/_metadata_panels.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<%= render AccessPanels::CourseReservesComponent.new(document: document) %>
<%= render AccessPanels::AtTheLibraryComponent.new(document: document) %>
<%= render AccessPanels::SimilarHoldingsComponent.new(document: document) %>

<% context = capture do %>
<%= render AccessPanels::AppearsInComponent.new(document: document) %>
Expand Down
15 changes: 15 additions & 0 deletions spec/components/access_panels/similar_holdings_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe AccessPanels::SimilarHoldingsComponent, type: :component do
pending "add some examples to (or delete) #{__FILE__}"

# it "renders something useful" do
# expect(
# render_inline(described_class.new(attr: "value")) { "Hello, components!" }.css("p").to_html
# ).to include(
# "Hello, components!"
# )
# end
end

0 comments on commit adf22e2

Please sign in to comment.