Skip to content

Commit

Permalink
Merge pull request #975 from nhsuk/make-copyight-text-settable-via-pa…
Browse files Browse the repository at this point in the history
…rams

Make copyright statement settable via params
  • Loading branch information
roshaanbajwa authored Jun 27, 2024
2 parents 17a449c + d543c8a commit dd7282b
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:new: **New features**

- Make nhsuk-page-width a default so that services can override it ([PR 971](https://github.com/nhsuk/nhsuk-frontend/pull/971))
- Make footer copyright statement configurable via Nunjucks parameters ([PR 975](https://github.com/nhsuk/nhsuk-frontend/pull/975))

## 8.2.0 - 12 June 2024

Expand Down
34 changes: 34 additions & 0 deletions app/components/footer/custom-copyright.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% set html_style = 'background-color: #f0f4f5;' %}
{% set title = 'Footer (custom copyright statement)' %}
{% from 'components/footer/macro.njk' import footer %}
{% extends 'layout.njk' %}

{% block body %}

{{ footer({
"copyright": "© East London NHS Foundation Trust",
"links": [
{
"URL": "#",
"label": "Accessibility statement"
},
{
"URL": "#",
"label": "Contact us"
},
{
"URL": "#",
"label": "Cookies"
},
{
"URL": "#",
"label": "Privacy policy"
},
{
"URL": "#",
"label": "Terms and conditions"
}
]
})}}

{% endblock %}
1 change: 1 addition & 0 deletions app/components/footer/footer-in-columns.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{% block body %}

{{ footer({
"copyright": "© Crown copyright",
"links": [
{
"URL": "#",
Expand Down
1 change: 1 addition & 0 deletions app/pages/examples.njk
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<li><a href="../components/fieldset/with-inputs.html">Fieldset with inputs</a></li>
<li><a href="../components/footer/index.html">Footer (default)</a></li>
<li><a href="../components/footer/footer-in-columns.html">Footer (columns)</a></li>
<li><a href="../components/footer/custom-copyright.html">Footer (custom copyright statement)</a></li>
<li><a href="../components/header/index.html">Header (default)</a></li>
<li><a href="../components/header/header-navigation.html">Header with navigation</a></li>
<li><a href="../components/header/header-search.html">Header with search</a></li>
Expand Down
72 changes: 72 additions & 0 deletions packages/components/footer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Your copyright statement must reflect the ownership of your website or service.
{% from 'components/footer/macro.njk' import footer %}
{{ footer({
"copyright": "© Crown copyright",
"links": [
{
"URL": "#",
Expand Down Expand Up @@ -267,6 +268,76 @@ Your copyright statement must reflect the ownership of your website or service.
})}}
```

### Footer (custom copyright statement)

[Preview the footer (custom copyright statement) component](https://nhsuk.github.io/nhsuk-frontend/components/footer/custom-copyright.html)

#### HTML markup

```html
<footer role="contentinfo">
<div class="nhsuk-footer-container">
<div class="nhsuk-width-container">
<h2 class="nhsuk-u-visually-hidden">Support links</h2>
<div class="nhsuk-footer">
<ul class="nhsuk-footer__list">
<li class="nhsuk-footer__list-item nhsuk-footer-default__list-item">
<a class="nhsuk-footer__list-item-link" href="#">Accessibility statement</a>
</li>
<li class="nhsuk-footer__list-item nhsuk-footer-default__list-item">
<a class="nhsuk-footer__list-item-link" href="#">Contact us</a>
</li>
<li class="nhsuk-footer__list-item nhsuk-footer-default__list-item">
<a class="nhsuk-footer__list-item-link" href="#">Cookies</a>
</li>
<li class="nhsuk-footer__list-item nhsuk-footer-default__list-item">
<a class="nhsuk-footer__list-item-link" href="#">Privacy policy</a>
</li>
<li class="nhsuk-footer__list-item nhsuk-footer-default__list-item">
<a class="nhsuk-footer__list-item-link" href="#">Terms and conditions</a>
</li>
</ul>
<div>
<p class="nhsuk-footer__copyright">&copy; East London NHS Foundation Trust</p>
</div>
</div>
</div>
</div>
</footer>
```

#### Nunjucks macro

```
{% from 'components/footer/macro.njk' import footer %}
{{ footer({
"copyright": "© East London NHS Foundation Trust",
"links": [
{
"URL": "#",
"label": "Accessibility statement"
},
{
"URL": "#",
"label": "Contact us"
},
{
"URL": "#",
"label": "Cookies"
},
{
"URL": "#",
"label": "Privacy policy"
},
{
"URL": "#",
"label": "Terms and conditions"
}
]
})}}
```

### Nunjucks arguments

The footer Nunjucks macro takes the following arguments:
Expand All @@ -282,6 +353,7 @@ The footer Nunjucks macro takes the following arguments:
| **linksColumn3** | array | No | Array of third column of navigation items for use in the footer. |
| **linksColumn3.[].url** | string | No | The href of a navigation item in the third column of the footer. |
| **linksColumn3.[].label** | string | No | The label of a navigation item in the third column of the footer. |
| **copyright** | string | No | Optional text for the copyright notice in the footer. Defaults to '© NHS England' |
| **classes** | string | No | Optional additional classes to add to the footer container. Separate each class with a space. |
| **attributes** | object | No | Any extra HTML attributes (for example data attributes) to add to the footer container. |
| **copyright** | string | No | The label for the copyright notice in the footer. |
Expand Down
6 changes: 4 additions & 2 deletions packages/components/footer/template.njk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{%- set copyrightText = params.copyright if params.copyright else '© NHS England' -%}

<footer role="contentinfo">
<div class="nhsuk-footer-container">
<div class="nhsuk-width-container">
Expand Down Expand Up @@ -29,7 +31,7 @@
{%- endfor %}
</ul>
<div>
<p class="nhsuk-footer__copyright">&copy; NHS England</p>
<p class="nhsuk-footer__copyright">{{ copyrightText }}</p>
</div>
</div> {# close nhsuk-footer #}
{% else %}
Expand Down Expand Up @@ -69,7 +71,7 @@
{%- endif %}
</div> {# close nhsuk-footer #}
<div>
<p class="nhsuk-footer__copyright">&copy; Crown copyright</p>
<p class="nhsuk-footer__copyright">{{ copyrightText }}</p>
</div>
{% endif %}
</div> {# close nhsuk-width-container #}
Expand Down
4 changes: 4 additions & 0 deletions tests/backstop/backstop.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ module.exports = {
label: 'Footer (columns)',
url: `${TEST_URL}/footer/footer-in-columns.html`,
},
{
label: 'Footer (custom copyright statement)',
url: `${TEST_URL}/footer/custom-copyright.html`,
},
{
label: 'Fieldset',
url: `${TEST_URL}/fieldset/index.html`,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dd7282b

Please sign in to comment.