Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subtitle to site masthead. #612

Merged
merged 3 commits into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/assets/stylesheets/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,11 @@ header.lux {
}
}
}

.site-subtitle {
min-height: 35px;
}
.masthead > .site-title-container > .site-title.h1 {
padding-bottom: 0;
margin-bottom: 0;
}
10 changes: 9 additions & 1 deletion app/views/shared/_masthead.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@
<% elsif current_exhibit %>
<%= current_exhibit.title %>
<% @subtitle ||= current_exhibit.subtitle %>
<div class="site-subtitle">
<% if @subtitle.present? %>
<small dir='<%= @subtitle.dir %>'><%= @subtitle %></small>
<small dir='<%= @subtitle.dir %>'><%= @subtitle %></small>
<% end %>
</div>
<% elsif @masthead_title %>
<%= @masthead_title %>
<% @subtitle ||= current_site.subtitle %>
<div class="site-subtitle">
<% if @subtitle.present? %>
<small dir='<%= @subtitle.dir %>'><%= @subtitle %></small>
<% end %>
</div>
<% end %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion spec/features/exhibit_home_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
visit spotlight.exhibit_root_path exhibit
expect(page).not_to have_link 'Dashboard'
expect(page).not_to have_link 'Edit'
expect(page).to have_selector ".site-title > small[dir='rtl']"
expect(page).to have_selector ".site-title small[dir='rtl']"
end
end
end
50 changes: 50 additions & 0 deletions spec/views/shared/_masthead.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

require 'rails_helper'

describe 'shared/_masthead', type: :view do
let(:exhibit) { FactoryBot.create(:exhibit, subtitle: 'Some exhibit') }
let(:masthead) { nil }

before do
stub_template 'shared/_exhibit_navbar.html.erb' => 'navbar'
allow(view).to receive_messages(current_exhibit: exhibit,
current_masthead: masthead,
resource_masthead?: false,
render_breadcrumbs: false)
end

it 'has the site title and subtitle' do
render
expect(rendered).to have_selector '.h1', text: exhibit.title
expect(rendered).to have_selector 'small', text: exhibit.subtitle
end

context 'with an exhibit without a subtitle' do
before do
exhibit.update(subtitle: nil)
end

it 'does not include the subtitle' do
render
expect(rendered).not_to have_selector 'small'
end
end

context "with no exhibit" do
let(:exhibit) { nil }
let(:subtitle) { "Stuff" }

before do
site = instance_double(Spotlight::Site, subtitle: subtitle)
allow(view).to receive(:current_site).and_return(site)
assign(:masthead_title, "Title")
end

it "renders the site subtitle and title" do
render
expect(rendered).to have_selector 'small', text: subtitle
expect(rendered).to have_selector '.h1', text: "Title"
end
end
end