From 152a2de91f47ecf05eb363f96b69df66e6b3e955 Mon Sep 17 00:00:00 2001 From: Frankie Roberto Date: Wed, 5 Feb 2025 08:08:35 +0000 Subject: [PATCH 1/4] Add support for text param for Inset text This adds support for a `text` param for the Inset text component, for use where only a single paragraph is included. This means that instead of: ```njk {{ insetText({ html: "

This is a note.

" }) }} ``` you can do this: ```njk {{ insetText({ text: "This is a note." }) }} --- packages/components/inset-text/README.md | 3 ++- packages/components/inset-text/template.njk | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/components/inset-text/README.md b/packages/components/inset-text/README.md index fabc14d62..a0753fe51 100644 --- a/packages/components/inset-text/README.md +++ b/packages/components/inset-text/README.md @@ -35,7 +35,8 @@ The inset text Nunjucks macro takes the following arguments: | Name | Type | Required | Description | | -------------- | ------ | -------- | ------------------------------------------------------------------------------------------------- | -| **html** | string | Yes | HTML content to be used within the inset text component. | +| **html** | string | No | HTML content to be used within the inset text component. | +| **text** | string | No | Text content to be used within the inset text component. | | **classes** | string | No | Optional additional classes to add to the inset text container. Separate each class with a space. | | **attributes** | object | No | Any extra HTML attributes (for example data attributes) to add to the inset text container. | diff --git a/packages/components/inset-text/template.njk b/packages/components/inset-text/template.njk index 0eb0427ad..91168f776 100644 --- a/packages/components/inset-text/template.njk +++ b/packages/components/inset-text/template.njk @@ -5,5 +5,9 @@ {{- nhsukAttributes(params.attributes) }}> Information: {# params.HTML supported for backwards compatibility - see issue #950 #} - {{ (params.html or params.HTML) | safe }} + {% if params.html or params.HTML %} + {{ (params.html or params.HTML) | safe }} + {% else %} +

{{ params.text }}

+ {% endif %} From 22b8d38b2356ce50c18f41c04ffb2d6fd18d56ed Mon Sep 17 00:00:00 2001 From: Frankie Roberto Date: Wed, 5 Feb 2025 08:11:52 +0000 Subject: [PATCH 2/4] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ceafebac2..dc246d2f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +:new: **New features** + +- Adds `text` param for Inset text ([PR 1113](https://github.com/nhsuk/nhsuk-frontend/pull/1113)) + :wrench: **Fixes** - Fix appearance of the select element for more consistency between browsers and OS ([Issue 527](https://github.com/nhsuk/nhsuk-service-manual-community-backlog/issues/527)) From 22f1bf3e74205ff397458851d41619d5f3f86bec Mon Sep 17 00:00:00 2001 From: Frankie Roberto Date: Wed, 5 Feb 2025 10:09:49 +0000 Subject: [PATCH 3/4] Improve indenting Co-authored-by: Colin Rotherham --- packages/components/inset-text/template.njk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/components/inset-text/template.njk b/packages/components/inset-text/template.njk index 91168f776..fe39e048f 100644 --- a/packages/components/inset-text/template.njk +++ b/packages/components/inset-text/template.njk @@ -5,9 +5,9 @@ {{- nhsukAttributes(params.attributes) }}> Information: {# params.HTML supported for backwards compatibility - see issue #950 #} - {% if params.html or params.HTML %} - {{ (params.html or params.HTML) | safe }} - {% else %} + {% if params.html or params.HTML -%} + {{ (params.html or params.HTML) | safe | trim | indent(2) }} + {%- else %}

{{ params.text }}

{% endif %} From 12c4765d9848a6a615411b40b180f7c751dec391 Mon Sep 17 00:00:00 2001 From: anandamaryon1 Date: Wed, 12 Feb 2025 14:09:10 +0000 Subject: [PATCH 4/4] update changelog --- CHANGELOG.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aedcf18d..a7c39cec5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,12 @@ # NHS.UK frontend Changelog -## Unreleased +## 9.2.0 - 12 February 2025 :new: **New features** - Adds `text` param for Inset text ([PR 1113](https://github.com/nhsuk/nhsuk-frontend/pull/1113)) - Make it easier to set checkbox and radio checked items ([PR 1105](https://github.com/nhsuk/nhsuk-frontend/pull/1105)) -## 9.2.0 - 12 February 2025 - :wrench: **Fixes** - Fix appearance of the select element for more consistency between browsers and OS ([Issue 527](https://github.com/nhsuk/nhsuk-service-manual-community-backlog/issues/527))