Skip to content

Commit 6e36866

Browse files
Bump NHS App frontend v5.0.0 (#381)
1 parent d5037a9 commit 6e36866

160 files changed

Lines changed: 2266 additions & 1363 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eleventy.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'path'
22
import nunjucks from 'nunjucks'
3-
import sass from 'sass'
3+
import * as sass from 'sass'
44
import fs from 'fs-extra'
55
import { EleventyHtmlBasePlugin } from '@11ty/eleventy'
66
import syntaxHighlight from '@11ty/eleventy-plugin-syntaxhighlight'
@@ -10,9 +10,6 @@ import anchor from 'markdown-it-anchor'
1010
import matter from 'gray-matter'
1111
import prettier from 'prettier'
1212

13-
// Import redirects from separate file
14-
import redirects from './redirects.js'
15-
1613
const nunjucksEnv = nunjucks.configure([
1714
// Our own styles and assets
1815
'src/styles',
@@ -22,9 +19,11 @@ const nunjucksEnv = nunjucks.configure([
2219
'docs/_includes',
2320
'docs/assets',
2421

25-
// NHS.UK frontend components
26-
'node_modules/nhsuk-frontend/packages/components',
27-
'node_modules/nhsuk-frontend/packages/macros'
22+
// NHS.UK frontend components (updated for v10)
23+
'node_modules/nhsuk-frontend/dist', // allow resolving paths like nhsuk/macros/attributes.njk
24+
'node_modules/nhsuk-frontend/dist/nhsuk',
25+
'node_modules/nhsuk-frontend/dist/nhsuk/components',
26+
'node_modules/nhsuk-frontend/dist/nhsuk/macros'
2827
])
2928

3029
export default function (eleventyConfig) {
@@ -58,27 +57,23 @@ export default function (eleventyConfig) {
5857
// Watch for changes in these directories and files
5958
eleventyConfig.addWatchTarget('./src/')
6059
eleventyConfig.addWatchTarget('./docs/assets/')
61-
eleventyConfig.addWatchTarget('./redirects.js') // Watch redirects file for changes
6260

6361
// Add images to docs
6462
eleventyConfig.addPassthroughCopy('docs/assets/images')
6563

66-
// Add NHSUK frontend JS components to docs
64+
// Add NHSUK frontend JS/components
6765
eleventyConfig.addPassthroughCopy({
68-
'node_modules/nhsuk-frontend/packages': 'nhsuk-frontend'
66+
'node_modules/nhsuk-frontend/dist': 'nhsuk-frontend/dist'
6967
})
7068

71-
// Add NHSUK frontend compiled JS/CSS to docs
69+
// Copy the NHS assets folder to /assets so default assetPath (/assets) works
7270
eleventyConfig.addPassthroughCopy({
73-
'node_modules/nhsuk-frontend/dist': 'nhsuk-frontend/dist'
71+
'node_modules/nhsuk-frontend/dist/nhsuk/assets': 'assets'
7472
})
7573

7674
// Add syntax highlighting to code blocks
7775
eleventyConfig.addPlugin(syntaxHighlight)
7876

79-
// Make redirects available as global data
80-
eleventyConfig.addGlobalData('redirects', redirects)
81-
8277
eleventyConfig.addTemplateFormats('scss')
8378
eleventyConfig.addExtension('scss', {
8479
outputFileExtension: 'css',
@@ -117,6 +112,12 @@ export default function (eleventyConfig) {
117112
.trim()
118113
let { data, content: nunjucksCode } = matter(exampleFile)
119114

115+
// Always show Nunjucks tab unless explicitly disabled
116+
let showNunjucksAuto = true
117+
if (typeof data.showNunjucks === 'boolean') {
118+
showNunjucksAuto = data.showNunjucks
119+
}
120+
120121
const rawHtmlCode = nunjucksEnv.renderString(nunjucksCode)
121122
const prettyHtmlCode = await prettier.format(rawHtmlCode, {
122123
parser: 'html'
@@ -138,7 +139,9 @@ export default function (eleventyConfig) {
138139
hub: data.hub,
139140
backlink: data.backlink || data.backLink || false,
140141
backLinkHref: data.backLinkHref,
141-
backLinkText: data.backLinkText
142+
backLinkText: data.backLinkText,
143+
arguments: data.arguments, // existing
144+
showNunjucks: showNunjucksAuto // computed visibility
142145
}
143146
return nunjucksEnv.render('example.njk', templateData)
144147
})

CHANGELOG.md

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,183 @@
11
# NHS App Frontend Changelog
22

3+
## `v5.0.0` - UNRELEASED
4+
5+
### 💥 Breaking changes
6+
7+
Bumped `nhsuk-frontend` version to `v10.0.0` in [pull request #378](https://github.com/nhsuk/nhsapp-frontend/pull/378) - details are in the [nhsuk frontend release notes](https://github.com/nhsuk/nhsuk-frontend/releases).
8+
9+
#### Button group
10+
11+
Deprecated `nhsapp-button-group` component in [pull request #378](https://github.com/nhsuk/nhsapp-frontend/pull/378), as now available in `nhsuk-frontend`.
12+
13+
Swap `nhsapp-button-group` → with `nhsuk-button-group`.
14+
15+
Before:
16+
17+
```
18+
<div class="nhsapp-button-group">
19+
<button class="nhsuk-button nhsapp-button">
20+
Continue
21+
</button>
22+
<button class="nhsuk-button nhsuk-button--secondary nhsapp-button">
23+
Try again
24+
</button>
25+
</div>
26+
```
27+
28+
After:
29+
30+
```
31+
<div class="nhsuk-button-group">
32+
<button class="nhsuk-button nhsapp-button">
33+
Continue
34+
</button>
35+
<button class="nhsuk-button nhsuk-button--secondary nhsapp-button">
36+
Try again
37+
</button>
38+
</div>
39+
```
40+
41+
#### Section heading
42+
43+
Deprecated `nhsapp-section heading` component in [pull request #378](https://github.com/nhsuk/nhsapp-frontend/pull/378).
44+
45+
A heading and description option has been added to the `cardGroup`.
46+
47+
Before:
48+
49+
```
50+
<div class="nhsapp-section-heading">
51+
<h2 class="nhsuk-heading-s">Upcoming appointments</h2>
52+
</div>
53+
<p class="nhsuk-u-margin-bottom-5">1 upcoming appointment</p>
54+
<ul class="nhsapp-cards nhsapp-cards--stacked">
55+
<li class="nhsapp-card">
56+
...
57+
</li>
58+
</ul>
59+
```
60+
61+
After:
62+
63+
```
64+
<h2 class="nhsapp-cards__heading">Upcoming appointments</h2>
65+
<p class="nhsapp-cards__description">1 upcoming appointment</p>
66+
<ul class="nhsapp-cards nhsapp-cards--stacked">
67+
<li class="nhsapp-card">
68+
...
69+
</li>
70+
</ul>
71+
```
72+
73+
Custom html can be added using `params.headingHtml`, that will support the depreaction of the `view all` link, for example:
74+
75+
```
76+
{{ nhsappCardGroup({
77+
stacked: true,
78+
headingHtml:
79+
'<div class="nhsapp-cards__heading" style="justify-content: space-between; align-items: center; display: flex;">
80+
<h2 class="nhsuk-heading-s nhsuk-u-margin-bottom-0">Services</h2>
81+
<a class="nhsuk-u-font-size-19 nhsuk-link nhsuk-link--no-visited-state nhsuk-u-nowrap" href="#">View all <span class="nhsuk-u-visually-hidden">services</span></a>
82+
</div>',
83+
cards: [
84+
{
85+
...
86+
}
87+
]
88+
}) }}
89+
```
90+
91+
#### Icons
92+
93+
Updated icon names, following nhsuk frontend naming conventions in [pull request #381](https://github.com/nhsuk/nhsapp-frontend/pull/389).
94+
95+
Before:
96+
97+
`nhsapp-icon nhsapp-icon__account`
98+
99+
After:
100+
101+
`nhsapp-icon nhsapp-icon--account`
102+
103+
#### Card links
104+
105+
Replaced `params.html` with `params.descriptionHtml` in [pull request 403](https://github.com/nhsuk/nhsapp-frontend/pull/403).
106+
107+
Before:
108+
109+
```
110+
{{ nhsappCard({
111+
title: '...',
112+
html: '...'
113+
}) }}
114+
```
115+
116+
After:
117+
118+
```
119+
{{ nhsappCard({
120+
title: '...',
121+
descriptionHtml: '...'
122+
}) }}
123+
```
124+
125+
Updated logic for a card with no link and removed `params.readOnly`.
126+
127+
Before:
128+
129+
```
130+
{{ nhsappCard({
131+
title: 'Card title',
132+
readOnly: 'true'
133+
}) }}
134+
```
135+
136+
After:
137+
138+
```
139+
{{ nhsappCard({
140+
title: 'Card title'
141+
}) }}
142+
```
143+
144+
Removed the card link with an icon in [pull request 405](https://github.com/nhsuk/nhsapp-frontend/pull/405).
145+
146+
## 🆕 New features
147+
148+
### New (web) header component
149+
150+
Added (web) header component in [pull request #390](https://github.com/nhsuk/nhsapp-frontend/pull/390), extending the NHS design system header and adding modifier classes, `nhsapp-u-hide-from-tablet` and `nhsapp-u-hide-until-tablet`, to show and hide nav items on different screen sizes.
151+
152+
### New NHS App colours
153+
154+
Added NHS App colours in [pull request #389](https://github.com/nhsuk/nhsapp-frontend/pull/392).
155+
156+
These are tints and shades extended from the NHS design system used on the NHS App tag and card links components.
157+
158+
Example:
159+
160+
`nhsapp-colour("green-light")`
161+
162+
Before:
163+
164+
`$color_tag-green-background: #c9e6d8;`
165+
166+
After:
167+
168+
`$color_tag-green-background: nhsapp-colour("green-light");`
169+
170+
### Card links
171+
172+
Updated card links component styling in [pull request #382](https://github.com/nhsuk/nhsapp-frontend/pull/382).
173+
174+
Added new variants for the:
175+
176+
- **Account card** - using the class `nhsapp-card--blue-light`.
177+
- **Campaign card** - using the classes `nhsapp-card--blue-dark` and `nhsapp-card--with-media`.
178+
179+
Added `isListItem` argument to `cardGroup` macro. If true (default) wrapper is `<ul>` with each card as `<li>`. If false uses `<div>`.
180+
3181
## `v4.0.0` - 17 June 2025
4182

5183
### Breaking changes

docs/_data/redirects.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Redirects configuration (auto-loaded by Eleventy because it is in docs/_data)
3+
* Each object needs a leading and trailing slash on `from` so the generated
4+
* permalink produces /path/index.html
5+
*/
6+
export default [
7+
{
8+
from: '/components/panel/',
9+
to: 'https://service-manual.nhs.uk/design-system/components/panel'
10+
},
11+
{
12+
from: '/patterns/confirmation-page/',
13+
to: 'https://service-manual.nhs.uk/design-system/patterns/confirmation-page'
14+
},
15+
{
16+
from: '/get-started/github-and-heroku/',
17+
to: '/get-started/nhsapp-prototype/'
18+
}
19+
// Add more redirects here as needed
20+
]

docs/_includes/example.njk

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,21 @@
2424
</div>
2525

2626
<div class="app-tabs" data-module="app-tabs">
27+
{% set showNunjucksTab = showNunjucks is not defined or showNunjucks != false %}
2728
<ul class="app-tabs__list" role="tablist">
28-
<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab nhsuk-link--no-visited-state" href="#html-default-{{ id }}" role="tab" id="tab_html-default-{{ id }}" aria-controls="html-default-{{ id }}">HTML</a></li>
29-
<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab nhsuk-link--no-visited-state" href="#nunjucks-default-{{ id }}" role="tab" id="tab_nunjucks-default-{{ id }}" aria-controls="nunjucks-default-{{ id }}">Nunjucks</a></li>
29+
{%- if showNunjucksTab -%}
30+
<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab nhsuk-link--no-visited-state" href="#html-default-{{ id }}" role="tab" id="tab_html-default-{{ id }}" aria-controls="html-default-{{ id }}">HTML</a></li>
31+
<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab nhsuk-link--no-visited-state" href="#nunjucks-default-{{ id }}" role="tab" id="tab_nunjucks-default-{{ id }}" aria-controls="nunjucks-default-{{ id }}">Nunjucks</a></li>
32+
{%- else -%}
33+
<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab nhsuk-link--no-visited-state" href="#html-default-{{ id }}" role="tab" id="tab_html-default-{{ id }}" aria-controls="html-default-{{ id }}">HTML</a></li>
34+
{%- endif -%}
3035
{%- if jsCode %}<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab nhsuk-link--no-visited-state" href="#js-default-{{ id }}" role="tab" id="tab_js-default-{{ id }}" aria-controls="js-default-{{ id }}">JavaScript</a></li>{% endif -%}
3136
{%- if figmaLink %}<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab nhsuk-link--no-visited-state" href="#figma-default-{{ id }}" role="tab" id="tab_figma-default-{{ id }}" aria-controls="figma-default-{{ id }}">Figma</a></li>{% endif -%}
3237
{%- if vueLink %}<li class="app-tabs__list-item" role="presentation"><a class="app-tabs__tab nhsuk-link--no-visited-state" href="#vue-default-{{ id }}" role="tab" id="tab_vue-default-{{ id }}" aria-controls="vue-default-{{ id }}">Vue</a></li>{% endif -%}
3338
</ul>
3439

3540
<div class="app-tabs__panel app-tabs__panel--hidden" id="html-default-{{ id }}" role="tabpanel" aria-labelledby="tab_html-default-{{ id }}">
36-
<button class="app-copy__button app-u-hidden" data-module="app-copy" data-clipboard-target="#html-default-{{ id }}-code">Copy code</button>
41+
<button class="app-copy__button" data-module="app-copy" data-clipboard-target="#html-default-{{ id }}-code">Copy code</button>
3742
<div id="html-default-{{ id }}-code">
3843
{%- highlight "html" -%}
3944
{{ htmlCode | safe }}
@@ -42,23 +47,35 @@
4247
</div>
4348

4449
<div class="app-tabs__panel app-tabs__panel--hidden" id="nunjucks-default-{{ id }}" role="tabpanel" aria-labelledby="tab_nunjucks-default-{{ id }}">
45-
<button class="app-copy__button app-u-hidden" data-module="app-copy" data-clipboard-target="#nunjucks-default-{{ id }}-code">Copy code</button>
4650

4751
{%- if arguments -%}
48-
<details class="nhsuk-details nhsuk-u-padding-3" data-module="nhsuk-details">
52+
<details class="nhsuk-details nhsuk-u-padding-top-4 nhsuk-u-padding-left-4 nhsuk-u-padding-right-4" data-module="nhsuk-details">
4953
<summary class="nhsuk-details__summary">
5054
<span class="nhsuk-details__summary-text">
5155
Nunjucks macro options
5256
</span>
5357
</summary>
5458
<div class="nhsuk-details__text">
55-
56-
{% include "./arguments/" + arguments + ".md" %}
57-
59+
<p>Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.</p>
60+
<p>Some options are required for the macro to work; these are marked as "Required" in the option description.</p>
61+
<p>If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against <a href="https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting">cross-site scripting exploits</a>.</p>
62+
{% if arguments %}
63+
{% set macroOptionsPath = "nhsapp/components/" + arguments + "/macro-options.md" %}
64+
{% if arguments == "card" %}
65+
{% set macroOptionsPath = "nhsapp/components/card/macro-options-card.md" %}
66+
{% elif arguments == "card-group" %}
67+
{% set macroOptionsPath = "nhsapp/components/card/macro-options-card-group.md" %}
68+
{% endif %}
69+
<div class="app-table--scroll">
70+
{% include macroOptionsPath ignore missing %}
71+
</div>
72+
{% endif %}
5873
</div>
5974
</details>
6075
{%- endif -%}
6176

77+
<button class="app-copy__button" data-module="app-copy" data-clipboard-target="#nunjucks-default-{{ id }}-code">Copy code</button>
78+
6279
<div id="nunjucks-default-{{ id }}-code">
6380

6481
```jinja2

0 commit comments

Comments
 (0)