Skip to content

Commit

Permalink
Add configurable banner to the top of page (#706)
Browse files Browse the repository at this point in the history
* Add configurable banner to the top of page

Co-authored-by: Bess Sadler <bess@users.noreply.github.com>
Co-authored-by: Sean Warren <seanwarren77@users.noreply.github.com>

* Update banner partial

* Rubocop

---------

Co-authored-by: Bess Sadler <bess@users.noreply.github.com>
Co-authored-by: Sean Warren <seanwarren77@users.noreply.github.com>
  • Loading branch information
3 people authored May 10, 2024
1 parent 0af4863 commit 23aee49
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/assets/stylesheets/_banner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#banner {
text-align: center;
background-color: #e1f0fb;
padding: 20px 0px 10px 0px;
border-bottom: #0060a7 solid 2px;
color: #0060a7;
h1 {
font-size: 24px;
font-weight: bold;
}
p {
font-size: 18px;
}
a {
text-decoration: underline;
}
}

@media all and (max-width: 860px) {
#banner {
padding: 10px 3px 5px 3px;
}
}
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

@import "settings";
@import "banner";
@import "header";
@import "footer";
@import "bootstrap";
12 changes: 12 additions & 0 deletions app/helpers/banner_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require "yaml"

module BannerHelper
def banner_content
@yaml_data = YAML.load_file("config/banner.yml")
return false if @yaml_data[Rails.env].nil?
@banner_title = @yaml_data[Rails.env]["title"]
@banner_body = @yaml_data[Rails.env]["body"]
end
end
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
</head>

<body>
<%= render partial: 'shared/banner' %>
<%= render partial: 'shared/header' %>
<div class="container">
<% if flash[:alert] %>
Expand Down
6 changes: 6 additions & 0 deletions app/views/shared/_banner.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% if banner_content %>
<div id="banner">
<h1><%= sanitize @banner_title %></h1>
<p><%= sanitize @banner_body, attributes: %w(href target)%></p>
</div>
<% end %>
16 changes: 16 additions & 0 deletions config/banner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
development:
title: Welcome to the development site
body: This is a message for development
test:
title: Welcome to the <i>test</i> site
body: This is a <b>test</b> <a href="mailto:fake@princeton.edu">message.</a>
staging:
title: Welcome to TigerData (Staging)!
body: PRDS is proud to share our new website for the management of research data.
qa:
title: Welcome to TigerData (QA)!
body: PRDS is proud to share our new website for the management of research data.
production:
title: Welcome to TigerData!
body: PRDS is proud to share our new website for the management of research data.
10 changes: 10 additions & 0 deletions spec/system/banner_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

require "rails_helper"

describe "Website banner", type: :system, js: true do
it "has the banner on the homepage" do
visit "/"
expect(page).to have_css "#banner"
end
end

0 comments on commit 23aee49

Please sign in to comment.