-
Notifications
You must be signed in to change notification settings - Fork 20
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
Allow emergency banner and global bar in public layout component #1915
Changes from all commits
66cac97
203f13c
44466a7
a7abd28
e873713
0210e0b
6227cf0
0266a2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
.gem-c-layout-for-public { | ||
margin: 0; | ||
font-family: $govuk-font-family; | ||
} | ||
|
||
.gem-c-layout-for-public__blue-bar { | ||
background: $govuk-brand-colour; | ||
height: govuk-spacing(2); | ||
} | ||
|
||
.js-enabled .gem-c-layout-for-public__global-banner-wrapper { | ||
margin-top: - govuk-spacing(2); | ||
position: relative; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,33 @@ | ||
<% | ||
title ||= "GOV.UK - The best place to find government services and information" | ||
html_lang ||= "en" | ||
emergency_banner ||= nil | ||
full_width ||= false | ||
global_bar ||= nil | ||
html_lang ||= "en" | ||
layout_helper = GovukPublishingComponents::Presenters::PublicLayoutHelper.new(local_assigns) | ||
navigation_items ||= [] | ||
omit_header ||= false | ||
show_search = local_assigns.include?(:show_search) ? local_assigns[:show_search] : true | ||
layout_helper = GovukPublishingComponents::Presenters::PublicLayoutHelper.new(local_assigns) | ||
title ||= "GOV.UK - The best place to find government services and information" | ||
|
||
# This is a hack - but it's the only way I can find to not have two blue bars on | ||
# constrained width layouts. | ||
# | ||
# The full width layout hides the blue bar underneath the blar header bar - so | ||
# full width pages won't see the blue bar unless it's added by another component | ||
# - and for most pages that component is the global banner. | ||
# | ||
# The constrained width layout doesn't hide the blue bar - so having the global | ||
# banner on a constrained width layout means there are two blue bars. | ||
# | ||
# The global banner is shown with JavaScript, so users without JavaScript won't | ||
# see it. So the constrained width blue bar can't be turned off as then it'll be | ||
# off for everyone. | ||
# | ||
# This booleon adds a CSS class that shifts the banners up by the blue bar's | ||
# height, making the two blue bars overlap and appear as one. The class is added | ||
# when a) there's content for the emergency or global banner *and* b) when using | ||
# the contrained width layout. | ||
blue_bar_dedupe = !full_width && global_bar.present? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed, I think we can afford this bit of debt to be able to move on with the main objective. The global bar design is likely to change soon and I'd rather try to address it when iterating on it. |
||
-%> | ||
<!DOCTYPE html> | ||
<!--[if lt IE 9]><html class="lte-ie8" lang="<%= html_lang %>"><![endif]--> | ||
|
@@ -48,13 +71,31 @@ | |
<% unless omit_header %> | ||
<%= render "govuk_publishing_components/components/layout_header", { | ||
search: show_search, | ||
# layout-header will always have border-bottom, unless the layout is full width | ||
remove_bottom_border: full_width, | ||
navigation_items: navigation_items, | ||
|
||
# The (blue) bottom border needs to be underneath the emergency banner - | ||
# so it has been turned off and added in manually. | ||
remove_bottom_border: true, | ||
} %> | ||
<% end %> | ||
<div class="<%= "govuk-width-container" unless full_width %>" id="content"> | ||
|
||
<%= raw(emergency_banner) %> | ||
|
||
<% unless full_width %> | ||
<div class="gem-c-layout-for-public__blue-bar govuk-width-container"></div> | ||
<% end %> | ||
|
||
<% if global_bar.present? %> | ||
<%= content_tag("div", { | ||
class: blue_bar_dedupe ? "gem-c-layout-for-public__global-banner-wrapper" : nil, | ||
}) do %> | ||
<%= raw(global_bar) %> | ||
<% end %> | ||
<% end %> | ||
|
||
<div id="wrapper" class="<%= "govuk-width-container" unless full_width %>"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's unfortunate that we'll have to carry this id over, but it is used all over our tests, including e2e. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It took me an embarrassingly long while to realise that this was the reason that all the tests were failing! |
||
<%= yield :before_content %> | ||
<main class="govuk-main-wrapper"> | ||
<main class="govuk-main-wrapper" id="content"> | ||
<%= yield %> | ||
</main> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
<% | ||
product_name ||= nil | ||
environment ||= nil | ||
full_width ||= false | ||
search ||= false | ||
search_left ||= false | ||
navigation_items ||= [] | ||
navigation_aria_label ||= "Top level" | ||
navigation_items ||= [] | ||
product_name ||= nil | ||
remove_bottom_border ||= false | ||
search ||= false | ||
search_left ||= false | ||
width_class = full_width ? "govuk-header__container--full-width" : "govuk-width-container" | ||
|
||
header_classes = %w(gem-c-layout-header govuk-header) | ||
header_classes = %w[gem-c-layout-header govuk-header] | ||
header_classes << "gem-c-layout-header--#{environment}" if environment | ||
header_classes << "gem-c-layout-header--no-bottom-border" if remove_bottom_border | ||
header_classes << "gem-c-layout-header--search-left" if search_left | ||
|
@@ -28,18 +27,22 @@ | |
<div class="govuk-grid-column-full govuk-grid-column-one-third-from-desktop gem-c-layout-header__search"> | ||
<%= render "govuk_publishing_components/components/layout_header/search" %> | ||
</div> | ||
<div class="govuk-header__content gem-c-header__content govuk-grid-column-full"> | ||
<%= render "govuk_publishing_components/components/layout_header/navigation_items", navigation_items: navigation_items, navigation_aria_label: navigation_aria_label %> | ||
</div> | ||
<% if navigation_items.any? %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessary within the scope of this PR, but do we need any temporary selector for slimmer to be able to render the login for accounts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not that I can see in the accounts_shower.rb - both the logged in and logged out links need to be added using the |
||
<div class="govuk-header__content gem-c-header__content govuk-grid-column-full"> | ||
<%= render "govuk_publishing_components/components/layout_header/navigation_items", navigation_items: navigation_items, navigation_aria_label: navigation_aria_label %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<% else %> | ||
<div class="govuk-grid-row govuk-!-margin-left-0 govuk-!-margin-right-0"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔥 |
||
<div class="govuk-grid-row"> | ||
<div class="gem-c-layout-header__logo govuk-grid-column-two-thirds"> | ||
<%= render "govuk_publishing_components/components/layout_header/header_logo", environment: environment, product_name: product_name %> | ||
</div> | ||
<div class="govuk-header__content gem-c-header__content"> | ||
<%= render "govuk_publishing_components/components/layout_header/navigation_items", navigation_items: navigation_items, navigation_aria_label: navigation_aria_label %> | ||
</div> | ||
<% if navigation_items.any? %> | ||
<div class="govuk-header__content gem-c-header__content govuk-grid-column-full"> | ||
<%= render "govuk_publishing_components/components/layout_header/navigation_items", navigation_items: navigation_items, navigation_aria_label: navigation_aria_label %> | ||
</div> | ||
<% end %> | ||
<% if search %> | ||
<div class="govuk-grid-column-one-third gem-c-layout-header__search"> | ||
<%= render "govuk_publishing_components/components/layout_header/search" %> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<%= render 'govuk_publishing_components/components/layout_for_public', { | ||
title: "Example public page" | ||
emergency_banner: '<div class="govuk-width-container"><p class="govuk-body">This is the emergency banner slot.</p></div>', | ||
global_bar: '<div class="govuk-width-container govuk-!-margin-top-2"><p class="govuk-body">This is the global bar slot.</p></div>', | ||
title: "Example public page", | ||
} do %> | ||
<%= yield %> | ||
<% end %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌 can't wait to see them go!