Skip to content

Commit

Permalink
Change how phase banner styles are applied
Browse files Browse the repository at this point in the history
  • Loading branch information
querkmachine committed Apr 29, 2024
1 parent f2b5d17 commit db7625e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{% set assetPath = '' %}
{% set themeColor = 'blue' %}
{% set bodyClasses = 'app-body-class' %}
{% set headerClasses = 'app-header-class' %}
{% set containerClasses = "app-width-container--wide" %}

{% block pageTitle %}GOV.UK - Le meilleur endroit pour trouver des services gouvernementaux et de l'information{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
@include govuk-text-colour;

display: flex;
margin-top: 0;
margin-bottom: 0;
align-items: baseline;
margin: 0;
}

.govuk-phase-banner__content__tag {
Expand All @@ -40,4 +40,11 @@
display: table-cell;
vertical-align: middle;
}

// Teams can optionally decide to put the phase banner into the header
// instead. In that scenario, we need to apply some different styles to
// control the element's width.
.govuk-template__header .govuk-phase-banner__content {
@include govuk-width-container;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="govuk-phase-banner
{%- if params.classes %} {{ params.classes }}{% endif %}"
{{- govukAttributes(params.attributes) }}>
<p class="govuk-width-container govuk-phase-banner__content">
<p class="govuk-phase-banner__content">
{{ govukTag({
text: params.tag.text,
html: params.tag.html,
Expand Down
10 changes: 6 additions & 4 deletions packages/govuk-frontend/src/govuk/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
}) }}
{% endblock %}

<header>
{% block header %}
{{ govukHeader({}) }}
{% block headerContainer %}
<header class="govuk-template__header {%- if headerClasses %} {{ headerClasses }}{% endif %}">
{% block header %}
{{ govukHeader({}) }}
{% endblock %}
</header>
{% endblock %}
</header>

{% block main %}
<div class="govuk-width-container {%- if containerClasses %} {{ containerClasses }}{% endif %}">
Expand Down
26 changes: 24 additions & 2 deletions packages/govuk-frontend/src/govuk/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,37 @@ describe('Template', () => {
})
})

describe('header', () => {
it('can be overridden using the header block', () => {
describe('<header>', () => {
it('can have custom classes added using headerClasses', () => {
const $ = renderTemplate('govuk/template.njk', {
context: {
headerClasses: 'custom-header-class'
}
})

expect($('header').hasClass('custom-header-class')).toBeTruthy()
})

it('can be overridden using the headerContainer block', () => {
const $ = renderTemplate('govuk/template.njk', {
blocks: {
headerContainer: '<div class="my-header">header</div>'
}
})

expect($('.my-header')).toHaveLength(1)
expect($('.govuk-template__header')).toHaveLength(0)
})

it('content can be overridden using the header block', () => {
const $ = renderTemplate('govuk/template.njk', {
blocks: {
header: '<div class="my-header">header</div>'
}
})

expect($('.my-header')).toHaveLength(1)
expect($('.govuk-template__header')).toHaveLength(1)
expect($('.govuk-header')).toHaveLength(0)
})
})
Expand Down

0 comments on commit db7625e

Please sign in to comment.