Skip to content

Commit

Permalink
Merge pull request #4289 from alphagov/add_header
Browse files Browse the repository at this point in the history
Add header
  • Loading branch information
JamesCGDS authored Oct 17, 2024
2 parents 51d517d + dafcbde commit 736bf7b
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 1 deletion.
24 changes: 24 additions & 0 deletions app/assets/stylesheets/views/_landing_page.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@import "govuk_publishing_components/individual_component_support";

.landing-page-header {
// I've used the hex value for the background colour as it doesn't exist in the colour palette
background-color: #231F20;
}

.landing-page-header__blue-bar {
background-color: govuk-colour("blue");
height: govuk-spacing(2);
}

.landing-page-header__org {
padding-top: govuk-spacing(2);
padding-bottom: govuk-spacing(6);

// I've added this styling here rather than in the gem because it's application specific
// and it would introduce further work to make this variation work in the gem without
// affecting the other variants.
// TODO add this as a variant in the components gem.
.gem-c-organisation-logo__link:link:not(:hover) {
text-decoration: none;
}
}
10 changes: 10 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,14 @@ def wrapper_class(publication = nil)
def current_path_without_query_string
request.original_fullpath.split("?", 2).first
end

def remove_breadcrumbs(content_item)
remove_breadcrumbs = false

if content_item.respond_to?(:is_a_landing_page?) && content_item.is_a_landing_page?
remove_breadcrumbs = true
end

remove_breadcrumbs
end
end
24 changes: 24 additions & 0 deletions app/views/landing_page/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
<%
add_view_stylesheet("landing_page")
%>

<div class="landing-page-header">
<div class="govuk-width-container">
<div class="landing-page-header__blue-bar">
</div>

<%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: Hash.new, inverse: true %>

<div class="landing-page-header__org">
<%= render "govuk_publishing_components/components/organisation_logo", {
organisation: {
name: sanitize("Prime Minister's Office<br>10 Downing Street"),
url: "/government/organisations/prime-ministers-office-10-downing-street",
brand: "prime-ministers-office-10-downing-street",
crest: "eo",
},
inverse: true,
} %>
</div>
</div>
</div>

<div class="landing-page" id="content">
<% @content_item.blocks.each do |block| %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% if publication && publication.in_beta %>
<%= render 'govuk_publishing_components/components/phase_banner', phase: "beta" %>
<% end %>
<% unless current_page?(root_path) || !(publication || @calendar) %>
<% unless current_page?(root_path) || !(publication || @calendar) || remove_breadcrumbs(content_item) %>
<%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: content_item_hash %>
<% end %>
<% if local_assigns %>
Expand Down
1 change: 1 addition & 0 deletions config/initializers/dartsass.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"views/_place-list.scss" => "views/_place-list.css",
"views/_popular_links.scss" => "views/_popular_links.css",
"views/_travel-advice.scss" => "views/_travel-advice.css",
"views/_landing_page.scss" => "views/_landing_page.css",
"views/_landing_page/card.scss" => "views/_landing_page/card.css",
"views/_landing_page/hero.scss" => "views/_landing_page/hero.css",
"views/_landing_page/featured.scss" => "views/_landing_page/featured.css",
Expand Down
26 changes: 26 additions & 0 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,30 @@ def dummy_publication
expect(current_path_without_query_string).to eq("/foo/bar")
end
end

describe "#remove_breadcrumbs" do
describe "when is_landing_page? is true" do
let(:content_item) { ContentItem.new({ "schema" => "landing_page" }) }

it "removes breadcrumbs" do
expect(remove_breadcrumbs(content_item)).to eq(true)
end
end

describe "when is_landing_page? is false" do
let(:content_item) { ContentItem.new({ "schema" => "a_different_page" }) }

it "does not remove breadcrumbs" do
expect(remove_breadcrumbs(content_item)).to eq(false)
end
end

describe "when is_landing_page? is undefined" do
let(:content_item) { ContentItem.new({}) }

it "does not remove breadcrumbs" do
expect(remove_breadcrumbs(content_item)).to eq(false)
end
end
end
end

0 comments on commit 736bf7b

Please sign in to comment.