Skip to content

Commit 49ae676

Browse files
authored
Merge pull request #4625 from alphagov/bk-presenting-branded-examples
Add callout macro
2 parents c196a10 + 7cb988e commit 49ae676

10 files changed

Lines changed: 108 additions & 89 deletions

File tree

src/components/cookie-banner/index.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@ layout: layout-pane.njk
88
---
99

1010
{% from "_example.njk" import example %}
11-
{% from "_brand-callout.njk" import brandCallout %}
11+
{% from "_callout.njk" import callout %}
1212

1313
Allow users to accept or reject cookies which are not essential to making your service work.
1414

1515
{{ example({ group: "components", item: "cookie-banner", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
1616

17-
<strong class="govuk-tag brand-tag-green">
18-
Brand
19-
</strong>
17+
{% call callout({ tagText: "Brand", colour: "green" }) %}
18+
2019
<p class="govuk-body"><a href="#">See an example of the Cookie banner showing the refreshed GOV.UK branding</a>.</p>
2120

21+
{% endcall %}
22+
2223
If you use the page template, you'll also get the Cookie banner without having to add it, as it's included by default. However, if you want to customise the default Cookie banner, read the [page template guidance about customising components](/styles/page-template/#changing-template-content).
2324

24-
{% call brandCallout({ text: "Brand", classes: "brand-tag-green" }) %}
25+
{% call callout({ tagText: "Brand", colour: "green", isInset: "true" }) %}
2526

26-
<h2>Brand changes to the {{title}} component</h2>
27+
<h2 class="app-callout__heading">Brand changes to the {{title}} component</h2>
2728
<p class="govuk-body">From 25 June 2025, the {{title}} component will change to support a wider refresh of the GOV.UK brand. </p>
2829

2930
<p class="govuk-body">The Cookie banner component’s background colour will change to light blue.</p>

src/components/footer/index.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,24 @@ layout: layout-pane.njk
88
---
99

1010
{% from "_example.njk" import example %}
11-
{% from "_brand-callout.njk" import brandCallout %}
11+
{% from "_callout.njk" import callout %}
1212
{%- from "govuk/components/tag/macro.njk" import govukTag -%}
1313

1414
The GOV.UK footer provides copyright, licensing and other information about your service.
1515

1616
{{ example({ group: "components", item: "footer", example: "default", id: "default-1", html: true, nunjucks: true, open: false, size: "m", loading: "eager" }) }}
1717

18-
<strong class="govuk-tag brand-tag-green">
19-
Brand
20-
</strong>
18+
{% call callout({ tagText: "Brand", colour: "green" }) %}
19+
2120
<p class="govuk-body"><a href="#">See an example of the GOV.UK footer showing the refreshed GOV.UK branding</a>.</p>
2221

22+
{% endcall %}
23+
2324
If you use the page template, you'll also get the footer without having to add it, as it's included by default. However, if you want to customise the default footer, read the [page template guidance about customising components](/styles/page-template/#changing-template-content).
2425

25-
{% call brandCallout({ text: "Brand", classes: "brand-tag-green" }) %}
26+
{% call callout({ tagText: "Brand", colour: "green", isInset: "true" }) %}
2627

27-
<h2>Brand changes to the {{title}} component</h2><p class="govuk-body">From 25 June 2025, the {{title}} component will change to support a wider refresh of the GOV.UK brand.</p>
28+
<h2 class="app-callout__heading">Brand changes to the {{title}} component</h2><p class="govuk-body">From 25 June 2025, the {{title}} component will change to support a wider refresh of the GOV.UK brand.</p>
2829

2930
<p class="govuk-body">The updated {{title}} component:</p>
3031
<ul class="govuk-list">
@@ -48,7 +49,7 @@ Make it clear whether content is available for re-use - and if it is, under what
4849
### Update to refresh the GOV.UK brand
4950

5051
<strong class="govuk-tag brand-tag-green">
51-
Brand
52+
Brand<span class="govuk-visually-hidden"> note</span>
5253
</strong>
5354

5455
If you use the Nunjucks macro and page template across your service, you can enable the brand refresh by setting the page template’s `rebrand` option to `true`. This will automatically make all needed changes related to the brand refresh.

src/components/header/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ layout: layout-pane.njk
88
---
99

1010
{% from "_example.njk" import example %}
11-
{% from "_brand-callout.njk" import brandCallout %}
11+
{% from "_callout.njk" import callout %}
1212

1313
The GOV.UK header component tells users they’re using a service on GOV.UK and lets them use GOV.UK-wide tools. Also known as the GOV.UK masthead.
1414

1515
{{ example({ group: "components", item: "header", example: "default", id: "default-1", html: true, nunjucks: true, open: false, loading: "eager" }) }}
1616

17-
<strong class="govuk-tag brand-tag-green">
18-
Brand
19-
</strong>
17+
{% call callout({ tagText: "Brand", colour: "green" }) %}
18+
2019
<p class="govuk-body"><a href="#">See an example of the GOV.UK header showing the refreshed GOV.UK branding</a>.</p>
20+
{% endcall %}
2121

2222
If you use the page template, you'll also get the GOV.UK header without having to add it, as it's included by default. However, if you want to customise the default GOV.UK header, read the [page template guidance about customising components](/styles/page-template/#changing-template-content).
2323

24-
{% call brandCallout({ text: "Brand", classes: "brand-tag-green" }) %}
24+
{% call callout({ tagText: "Brand", colour: "green", isInset: "true" }) %}
2525

26-
<h2>Brand changes to the {{title}} component</h2>
26+
<h2 class="app-callout__heading">Brand changes to the {{title}} component</h2>
2727
<p class="govuk-body">From 25 June 2025, the {{title}} component will change to support a wider refresh of the GOV.UK brand. </p>
2828

2929
<p class="govuk-body">The updated {{title}} component:</p>
@@ -64,7 +64,7 @@ For guidance on how to plan your header and navigation, see the [Help users navi
6464
### Update to refresh the GOV.UK brand
6565

6666
<strong class="govuk-tag brand-tag-green">
67-
Brand
67+
Brand<span class="govuk-visually-hidden"> note</span>
6868
</strong>
6969

7070
If you use the Nunjucks macro and page template across your service, you can enable the brand refresh by setting the page template’s `rebrand` option to `true`. This will automatically make all needed changes related to the brand refresh.

src/components/service-navigation/index.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ layout: layout-pane.njk
88
---
99

1010
{% from "_example.njk" import example %}
11-
{% from "_brand-callout.njk" import brandCallout %}
11+
{% from "_callout.njk" import callout %}
1212
{% from "govuk/components/inset-text/macro.njk" import govukInsetText %}
1313

1414
Service navigation helps users understand that they’re using your service and lets them navigate around your service.
1515

16-
{% call brandCallout({ text: "Brand", classes: "brand-tag-green" }) %}
16+
{% call callout({ tagText: "Brand", colour: "green", isInset: "true" }) %}
1717

18-
<h2>Brand changes to the {{title}} component</h2><p class="govuk-body">From 25 June 2025, the {{title}} component will change to support a wider refresh of the GOV.UK brand.</p>
18+
<h2 class="app-callout__heading">Brand changes to the {{title}} component</h2><p class="govuk-body">From 25 June 2025, the {{title}} component will change to support a wider refresh of the GOV.UK brand.</p>
1919

2020
<p class="govuk-body">The updated {{title}} component:</p>
2121
<ul class="govuk-list">
@@ -27,11 +27,12 @@ Service navigation helps users understand that they’re using your service and
2727

2828
{{ example({ group: "components", item: "service-navigation", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
2929

30-
<strong class="govuk-tag brand-tag-green">
31-
Brand
32-
</strong>
30+
{% call callout({ tagText: "Brand", colour: "green" }) %}
31+
3332
<p class="govuk-body"><a href="#">See an example of the Service navigation showing the refreshed GOV.UK branding</a>.</p>
3433

34+
{% endcall %}
35+
3536
If you use the page template, you'll also get the Service navigation without having to add it, as it's included by default. However, if you want to customise the default Service navigation, read the [page template guidance about customising components](/styles/page-template/#changing-template-content).
3637

3738
## When to use this component
@@ -51,7 +52,7 @@ For guidance on how to plan your header and navigation, see the [Help users navi
5152
### Update to refresh the GOV.UK brand
5253

5354
<strong class="govuk-tag brand-tag-green">
54-
Brand
55+
Brand<span class="govuk-visually-hidden"> note</span>
5556
</strong>
5657

5758
If you use the Nunjucks macro and page template across your service, you can enable the brand refresh by setting the page template’s `rebrand` option to `true`. This will automatically make all needed changes related to the brand refresh.
@@ -67,7 +68,7 @@ Apply a class `govuk-header--full-width-border` to the GOV.UK header.
6768
{{ example({ group: "components", item: "service-navigation", example: "with-govuk-header", html: true, nunjucks: true, open: false }) }}
6869

6970
<strong class="govuk-tag brand-tag-green">
70-
Brand
71+
Brand<span class="govuk-visually-hidden"> note</span>
7172
</strong>
7273

7374
You do not need to change the bottom border of the updated GOV.UK header component with the refreshed GOV.UK branding.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Change callout <h2>'s to look like <h3>'s
2+
// Selector specificity needs to outweigh `.app-content h2`
3+
.app-callout {
4+
.app-callout__heading {
5+
@extend %govuk-heading-m;
6+
max-width: 30em;
7+
}
8+
9+
// Add highlight styling for callout content
10+
&:target {
11+
outline-offset: 6px;
12+
outline-style: solid;
13+
outline-width: 4px;
14+
}
15+
}
16+
17+
.app-callout__tag {
18+
margin-top: 1px;
19+
margin-top: govuk-spacing(2);
20+
margin-bottom: govuk-spacing(1);
21+
}
22+
23+
.app-callout--blue {
24+
border-left-color: govuk-colour("blue");
25+
26+
.app-callout__tag {
27+
color: #0f385c;
28+
background-color: #d2e2f1;
29+
}
30+
31+
&:target {
32+
outline-color: govuk-colour("blue");
33+
}
34+
}
35+
36+
.app-callout--green {
37+
border-left-color: #11875a;
38+
39+
&:target {
40+
outline-color: govuk-colour("green");
41+
}
42+
43+
.app-callout__tag {
44+
color: #09442d;
45+
background-color: #cfe7de;
46+
}
47+
}

src/stylesheets/main.scss

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ $app-code-color: #d13118;
4646

4747
// App-specific components
4848
@import "components/back-to-top";
49+
@import "components/callout";
4950
@import "components/category-nav";
5051
@import "components/contact-panel";
5152
@import "components/cookies-page";
@@ -414,22 +415,6 @@ pre .language-plaintext {
414415
background-color: $app-light-grey;
415416
}
416417

417-
.app-wcag-callout {
418-
border-left-color: govuk-colour("blue");
419-
}
420-
421-
// Change headings in WCAG callouts to look like H3s,
422-
// even though they semantically are H2s
423-
.app-wcag-callout h2 {
424-
@extend %govuk-heading-m;
425-
max-width: 30em;
426-
}
427-
428-
.app-wcag-callout__tag {
429-
margin-top: 1px;
430-
margin-bottom: govuk-spacing(2);
431-
}
432-
433418
.app-wcag-note {
434419
margin-top: govuk-spacing(6);
435420

@@ -443,28 +428,3 @@ pre .language-plaintext {
443428
.app-campaign-cookie-banner .govuk-grid-column-two-thirds {
444429
width: 100%;
445430
}
446-
447-
.brand-tag-blue {
448-
margin-top: govuk-spacing(2);
449-
margin-bottom: govuk-spacing(1);
450-
color: #0f385c;
451-
background-color: #d2e2f1;
452-
}
453-
454-
.brand-tag-green {
455-
margin-top: govuk-spacing(2);
456-
margin-bottom: govuk-spacing(1);
457-
color: #09442d;
458-
background-color: #cfe7de;
459-
}
460-
461-
.app-brand-callout {
462-
border-left-color: #11875a;
463-
}
464-
465-
// Change headings in WCAG callouts to look like H3s,
466-
// even though they semantically are H2s
467-
.app-brand-callout h2 {
468-
@extend %govuk-heading-m;
469-
max-width: 30em;
470-
}

views/partials/_brand-callout.njk

Lines changed: 0 additions & 17 deletions
This file was deleted.

views/partials/_callout.njk

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{% from "govuk/components/inset-text/macro.njk" import govukInsetText -%}
2+
{% from "govuk/components/tag/macro.njk" import govukTag -%}
3+
4+
{% macro callout(params) -%}
5+
{% set calloutContent -%}
6+
{{ govukTag({
7+
html: params.tagText + '<span class="govuk-visually-hidden"> note</span>',
8+
classes: "app-callout__tag"
9+
}) }}
10+
{% if params.heading -%}
11+
<h2 class="app-callout__heading">{{ params.heading }}</h2>
12+
{% endif -%}
13+
{{ caller() if caller else params.content | safe }}
14+
{% endset -%}
15+
16+
{% if params.isInset === "true" -%}
17+
{{ govukInsetText({
18+
id: params.id if params.id,
19+
html: calloutContent,
20+
classes: "app-callout app-callout--" + params.colour
21+
}) }}
22+
{% else -%}
23+
<div {% if params.id %}{{ params.id }} {% endif %}class="app-callout app-callout--{{params.colour}}" role="note">{{ calloutContent | trim | safe }}</div>
24+
{% endif -%}
25+
26+
{% endmacro %}

views/partials/_wcag-callout.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{% set tagContent -%}
66
{{- govukTag({
77
text: "WCAG 2.2",
8-
classes: "app-wcag-callout__tag"
8+
classes: "app-callout__tag"
99
}) }}
1010
<h2>
1111
{{ params.heading if params.heading else "New WCAG 2.2 criteria affect this " + params.type }}
@@ -25,6 +25,6 @@
2525

2626
{{ govukInsetText({
2727
html: tagContent,
28-
classes: "app-wcag-callout"
28+
classes: "app-callout app-callout--blue"
2929
}) }}
3030
{% endmacro %}

views/partials/_wcag-note.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="app-wcag-note" id="{{params.id}}" role="note">
55
{{ govukTag({
66
text: "WCAG 2.2",
7-
classes: "app-wcag-callout__tag"
7+
classes: "app-callout__tag"
88
}) }}
99
{{ caller() if caller else params.content | safe }}
1010
</div>

0 commit comments

Comments
 (0)