-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate EmbedThis component for media from the other viewers
Roll back changes in 1ce562b
- Loading branch information
Showing
6 changed files
with
137 additions
and
41 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
app/components/embed/media/embed_this_form_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<div class='sul-embed-embed-this-form'> | ||
<section> | ||
<h3 class='sul-embed-options-label modal-subheader'> | ||
Share link | ||
</h3> | ||
<div class='sul-embed-section'> | ||
<input type="text" name="sul-embed-purl-link" id='sul-embed-purl-link' value="<%= purl_url %>"> | ||
</div> | ||
</section> | ||
|
||
<section> | ||
<h3 class='sul-embed-options-label modal-subheader'> | ||
<label for='sul-embed-iframe-code'>Embed</label> | ||
</h3> | ||
<div class='sul-embed-section'> | ||
<textarea id='sul-embed-iframe-code' data-behavior='iframe-code'><%= render IframeComponent.new(viewer:) %></textarea> | ||
</div> | ||
<h4 class='sul-embed-options-label' id="select-options">Select options:</h4> | ||
<div class='sul-embed-section sul-embed-embed-title-section'> | ||
<input | ||
type='checkbox' | ||
id='sul-embed-embed-title' | ||
data-embed-attr='hide_title' | ||
<%= 'checked' unless request.hide_title? %> | ||
/> | ||
<label for='sul-embed-embed-title'> | ||
title | ||
<span class='sul-embed-embed-title'> (<%= purl_object_title %>)</span> | ||
</label> | ||
</div> | ||
<%= content %> | ||
<div class='sul-embed-section'> | ||
<input | ||
type='checkbox' | ||
id='sul-embed-embed' | ||
data-embed-attr='hide_embed' | ||
<%= 'checked' unless request.hide_embed_this? %> | ||
/> | ||
<label for='sul-embed-embed'>embed</label> | ||
</div> | ||
</section> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module Embed | ||
module Media | ||
class EmbedThisFormComponent < ViewComponent::Base | ||
def initialize(viewer:) | ||
@viewer = viewer | ||
end | ||
|
||
delegate :request, :purl_object, to: :viewer | ||
delegate :title, to: :purl_object, prefix: true | ||
delegate :purl_url, to: :purl_object | ||
|
||
attr_reader :viewer | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,33 @@ | ||
<div class='sul-embed-embed-this-form'> | ||
<section> | ||
<h3 class='sul-embed-options-label modal-subheader'> | ||
Share link | ||
</h3> | ||
<div class='sul-embed-section'> | ||
<input type="text" name="sul-embed-purl-link" id='sul-embed-purl-link' value="<%= purl_url %>"> | ||
</div> | ||
</section> | ||
|
||
<section> | ||
<h3 class='sul-embed-options-label modal-subheader'> | ||
<label for='sul-embed-iframe-code'>Embed</label> | ||
</h3> | ||
<div class='sul-embed-section'> | ||
<textarea id='sul-embed-iframe-code' data-behavior='iframe-code'><%= render IframeComponent.new(viewer:) %></textarea> | ||
</div> | ||
<h4 class='sul-embed-options-label' id="select-options">Select options:</h4> | ||
<div class='sul-embed-section sul-embed-embed-title-section'> | ||
<input | ||
type='checkbox' | ||
id='sul-embed-embed-title' | ||
data-embed-attr='hide_title' | ||
<span class='sul-embed-options-label' id="select-options">Select options:</span> | ||
<div class='sul-embed-section sul-embed-embed-title-section'> | ||
<input | ||
type='checkbox' | ||
id='sul-embed-embed-title' | ||
data-embed-attr='hide_title' | ||
<%= 'checked' unless request.hide_title? %> | ||
/> | ||
<label for='sul-embed-embed-title'> | ||
title | ||
<span class='sul-embed-embed-title'> (<%= purl_object_title %>)</span> | ||
</label> | ||
/> | ||
<label for='sul-embed-embed-title'> | ||
title | ||
<span class='sul-embed-embed-title'> (<%= purl_object_title %>)</span> | ||
</label> | ||
</div> | ||
<%= content %> | ||
<div class='sul-embed-section'> | ||
<input | ||
type='checkbox' | ||
id='sul-embed-embed' | ||
data-embed-attr='hide_embed' | ||
<%= 'checked' unless request.hide_embed_this? %> | ||
/> | ||
<label for='sul-embed-embed'>embed</label> | ||
</div> | ||
<div> | ||
<div class='sul-embed-options-label'> | ||
<label for='sul-embed-iframe-code'>Embed code:</label> | ||
</div> | ||
<%= content %> | ||
<div class='sul-embed-section'> | ||
<input | ||
type='checkbox' | ||
id='sul-embed-embed' | ||
data-embed-attr='hide_embed' | ||
<%= 'checked' unless request.hide_embed_this? %> | ||
/> | ||
<label for='sul-embed-embed'>embed</label> | ||
<textarea id='sul-embed-iframe-code' data-behavior='iframe-code'><%= render IframeComponent.new(viewer:) %></textarea> | ||
</div> | ||
</section> | ||
</div> | ||
</div> | ||
</div> |
48 changes: 48 additions & 0 deletions
48
spec/components/embed/media/embed_this_form_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Embed::Media::EmbedThisFormComponent, type: :component do | ||
let(:request) do | ||
Embed::Request.new(url: 'http://purl.stanford.edu/abc123') | ||
end | ||
let(:object) do | ||
instance_double(Embed::Purl, title: '', druid: '', all_resource_files: [], embargoed?: false, purl_url: 'https://stanford.edu/') | ||
end | ||
let(:viewer) { Embed::Viewer::File.new(request) } | ||
|
||
before do | ||
allow(request).to receive(:purl_object).and_return(object) | ||
end | ||
|
||
context 'without any content' do | ||
before do | ||
render_inline(described_class.new(viewer:)) | ||
end | ||
|
||
it 'has the form elements for updating the embed code' do | ||
expect(page.find('.sul-embed-options-label#select-options')).to have_content('Select options:') | ||
expect(page).to have_css('input#sul-embed-embed-title[type="checkbox"]') | ||
expect(page).to have_css('input#sul-embed-embed[type="checkbox"]') | ||
expect(page).to have_css('textarea#sul-embed-iframe-code') | ||
end | ||
end | ||
|
||
context 'with content' do | ||
before do | ||
with_controller_class EmbedController do | ||
render_inline(described_class.new(viewer:)) do | ||
vc_test_controller.helpers.tag :input, type: 'checkbox', id: 'sul-embed-embed-search' | ||
end | ||
end | ||
end | ||
|
||
it 'has the form elements for updating the embed code' do | ||
expect(page.find('.sul-embed-options-label#select-options')).to have_content('Select options:') | ||
expect(page).to have_css('input#sul-embed-embed-title[type="checkbox"]') | ||
expect(page).to have_css('input#sul-embed-embed-search[type="checkbox"]') | ||
expect(page).to have_css('input#sul-embed-embed[type="checkbox"]') | ||
expect(page).to have_css('textarea#sul-embed-iframe-code') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters