Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GOV.UK Frontend v5.9.0 #93

Merged
merged 8 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -55,7 +55,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
run: |
(cd tests/utils && nohup python -m flask run --port 3000 &)
wait-for-it localhost:3000
./govuk-frontend-diff http://localhost:3000 --govuk-frontend-version=v5.8.0 --exclude page-template --ci
./govuk-frontend-diff http://localhost:3000 --govuk-frontend-version=v5.9.0 --exclude page-template --ci
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/LandRegistry/govuk-frontend-jinja/compare/3.4.1...main)
## [Unreleased](https://github.com/LandRegistry/govuk-frontend-jinja/compare/3.5.0...main)

## [3.5.0](https://github.com/LandRegistry/govuk-frontend-jinja/releases/tag/3.5.0) - 05/03/2025

### Added

- [GOV.UK Frontend v5.9.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.9.0) support

## [3.4.1](https://github.com/LandRegistry/govuk-frontend-jinja/releases/tag/3.4.1) - 13/01/2025

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GOV.UK Frontend Jinja Macros

[![PyPI version](https://badge.fury.io/py/govuk-frontend-jinja.svg)](https://pypi.org/project/govuk-frontend-jinja/)
![govuk-frontend 5.8.0](https://img.shields.io/badge/govuk--frontend%20version-5.8.0-005EA5?logo=gov.uk&style=flat)
![govuk-frontend 5.9.0](https://img.shields.io/badge/govuk--frontend%20version-5.9.0-005EA5?logo=gov.uk&style=flat)
[![Python package](https://github.com/LandRegistry/govuk-frontend-jinja/actions/workflows/python-package.yml/badge.svg)](https://github.com/LandRegistry/govuk-frontend-jinja/actions/workflows/python-package.yml)

**GOV.UK Frontend Jinja is a [community tool](https://design-system.service.gov.uk/community/resources-and-tools/) of the [GOV.UK Design System](https://design-system.service.gov.uk/). The Design System team is not responsible for it and cannot support you with using it. Contact the [maintainers](#contributors) directly if you need [help](#support) or you want to request a feature.**
Expand All @@ -16,6 +16,7 @@ The following table shows the version of GOV.UK Frontend Jinja that you should u

| GOV.UK Frontend Jinja Version | Target GOV.UK Frontend Version |
| -------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [3.5.0](https://github.com/LandRegistry/govuk-frontend-jinja/releases/tag/3.5.0) | [5.9.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.9.0) |
| [3.4.1](https://github.com/LandRegistry/govuk-frontend-jinja/releases/tag/3.4.1) | [5.8.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.8.0) |
| [3.4.0](https://github.com/LandRegistry/govuk-frontend-jinja/releases/tag/3.4.0) | [5.7.1](https://github.com/alphagov/govuk-frontend/releases/tag/v5.7.1) |
| [3.3.0](https://github.com/LandRegistry/govuk-frontend-jinja/releases/tag/3.3.0) | [5.6.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.6.0) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
{%- set textareaDescriptionLength = params.maxwords or params.maxlength -%}
{%- set textareaDescriptionText = params.textareaDescriptionText or 'You can enter up to %{count} ' ~ ('words' if params.maxwords else 'characters') -%}
{%- set textareaDescriptionTextNoLimit = textareaDescriptionText | replace('%{count}', textareaDescriptionLength) if not hasNoLimit -%}
{%- set id = params.id if params.id else params.name -%}

{%- set countMessageHtml %}
{{ govukHint({
'text': textareaDescriptionTextNoLimit,
'id': params.id ~ '-info',
'id': id ~ '-info',
'classes': 'govuk-character-count__message' ~ (' ' ~ params.countMessage.classes if params.countMessage and params.countMessage.classes)
}) | trim }}
{% if params.formGroup and params.formGroup.afterInput %}
Expand Down Expand Up @@ -94,9 +95,9 @@
{%- endif -%}

{{ govukTextarea({
'id': params.id,
'id': id,
'name': params.name,
'describedBy': params.id ~ '-info',
'describedBy': id ~ '-info',
'rows': params.rows,
'spellcheck': params.spellcheck,
'value': params.value,
Expand All @@ -115,7 +116,7 @@
'classes': params.label.classes,
'isPageHeading': params.label.isPageHeading,
'attributes': params.label.attributes,
'for': params.id
'for': id
},
'hint': params.hint,
'errorMessage': params.errorMessage,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{% macro govukFileUpload(params) %}
{% from "govuk_frontend_jinja/macros/attributes.html" import govukAttributes %}
{% from "govuk_frontend_jinja/macros/i18n.html" import govukI18nAttributes %}
{% from "govuk_frontend_jinja/components/error-message/macro.html" import govukErrorMessage %}
{% from "govuk_frontend_jinja/components/hint/macro.html" import govukHint %}
{% from "govuk_frontend_jinja/components/label/macro.html" import govukLabel %}

{#- a record of other elements that we need to associate with the input using
aria-describedby – for example hints or error messages -#}
{% set describedBy = params.describedBy if params.describedBy else "" %}
{%- set describedBy = params.describedBy if params.describedBy else "" -%}
{%- set id = params.id if params.id else params.name -%}

<div class="govuk-form-group {%- if params.errorMessage %} govuk-form-group--error{% endif %} {%- if params.formGroup and params.formGroup.classes %} {{ params.formGroup.classes }}{% endif %}"
{{- govukAttributes(params.formGroup.attributes if params.formGroup) }}>
{{ govukLabel({
Expand All @@ -15,10 +18,10 @@
'classes': params.label.classes,
'isPageHeading': params.label.isPageHeading,
'attributes': params.label.attributes,
'for': params.id
'for': id
}) | trim | indent(2) }}
{% if params.hint %}
{% set hintId = params.id ~ '-hint' %}
{% set hintId = id ~ '-hint' %}
{% set describedBy = describedBy ~ ' ' ~ hintId if describedBy else hintId %}
{{ govukHint({
'id': hintId,
Expand All @@ -29,7 +32,7 @@
}) | trim | indent(2) }}
{% endif %}
{% if params.errorMessage %}
{% set errorId = params.id ~ '-error' %}
{% set errorId = id ~ '-error' %}
{% set describedBy = describedBy ~ ' ' ~ errorId if describedBy else errorId %}
{{ govukErrorMessage({
'id': errorId,
Expand All @@ -43,11 +46,45 @@
{% if params.formGroup and params.formGroup.beforeInput %}
{{ params.formGroup.beforeInput.html | safe | trim | indent(2) if params.formGroup and params.formGroup.beforeInput.html else params.formGroup.beforeInput.text }}
{% endif %}
<input class="govuk-file-upload {%- if params.classes %} {{ params.classes }}{% endif %} {%- if params.errorMessage %} govuk-file-upload--error{% endif %}" id="{{ params.id }}" name="{{ params.name }}" type="file"
{% if params.javascript %}
<div
class="govuk-drop-zone"
data-module="govuk-file-upload"
{{- govukI18nAttributes({
'key': 'choose-files-button',
'message': params.chooseFilesButtonText
}) -}}
{{- govukI18nAttributes({
'key': 'no-file-chosen',
'message': params.noFileChosenText
}) -}}
{{- govukI18nAttributes({
'key': 'multiple-files-chosen',
'messages': params.multipleFilesChosenText
}) -}}
{{- govukI18nAttributes({
'key': 'drop-instruction',
'message': params.dropInstructionText
}) -}}
{{- govukI18nAttributes({
'key': 'entered-drop-zone',
'message': params.enteredDropZoneText
}) -}}
{{- govukI18nAttributes({
'key': 'left-drop-zone',
'message': params.leftDropZoneText
}) -}}
>
{% endif %}
<input class="govuk-file-upload {%- if params.classes %} {{ params.classes }}{% endif %} {%- if params.errorMessage %} govuk-file-upload--error{% endif %}" id="{{ id }}" name="{{ params.name }}" type="file"
{%- if params.value %} value="{{ params.value }}"{% endif %}
{%- if params.disabled %} disabled{% endif %}
{%- if params.multiple %} multiple{% endif %}
{%- if describedBy %} aria-describedby="{{ describedBy }}"{% endif %}
{{- govukAttributes(params.attributes) }}>
{% if params.javascript %}
</div>
{% endif %}
{% if params.formGroup and params.formGroup.afterInput %}
{{ params.formGroup.afterInput.html | safe | trim | indent(2) if params.formGroup and params.formGroup.afterInput.html else params.formGroup.afterInput.text }}
{% endif %}
Expand Down
9 changes: 5 additions & 4 deletions govuk_frontend_jinja/templates/components/input/macro.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
{#- a record of other elements that we need to associate with the input using
aria-describedby – for example hints or error messages -#}
{% set describedBy = params.describedBy if params.describedBy else undefined -%}
{%- set id = params.id if params.id else params.name -%}

{%- set hasPrefix = true if params.prefix and (params.prefix.text or params.prefix.html) else false %}
{%- set hasSuffix = true if params.suffix and (params.suffix.text or params.suffix.html) else false %}
Expand All @@ -28,7 +29,7 @@
<input
{{- govukAttributes({
'class': classNames,
'id': params.id,
'id': id,
'name': params.name,
'type': params.type | default("text", true),
'spellcheck': {
Expand Down Expand Up @@ -84,10 +85,10 @@
'classes': params.label.classes,
'isPageHeading': params.label.isPageHeading,
'attributes': params.label.attributes,
'for': params.id
'for': id
}) | trim | indent(2) }}
{% if params.hint %}
{% set hintId = params.id ~ '-hint' %}
{% set hintId = id ~ '-hint' %}
{% set describedBy = describedBy ~ ' ' ~ hintId if describedBy else hintId %}
{{ govukHint({
'id': hintId,
Expand All @@ -98,7 +99,7 @@
}) | trim | indent(2) }}
{% endif %}
{% if params.errorMessage %}
{% set errorId = params.id ~ '-error' %}
{% set errorId = id ~ '-error' %}
{% set describedBy = describedBy ~ ' ' ~ errorId if describedBy else errorId %}
{{ govukErrorMessage({
'id': errorId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
{% from "govuk_frontend_jinja/components/button/macro.html" import govukButton -%}
{% from "govuk_frontend_jinja/components/input/macro.html" import govukInput -%}

{%- set id = params.id if params.id else params.name -%}

{% set attributesHtml -%}
{{- ' data-module="govuk-password-input"' | safe }}

Expand Down Expand Up @@ -52,7 +54,7 @@
'classes': "govuk-button--secondary govuk-password-input__toggle govuk-js-password-input-toggle" ~ (" " ~ params.button.classes if params.button and params.button.classes),
'text': params.showPasswordText | default("Show"),
'attributes': {
"aria-controls": params.id,
"aria-controls": id,
"aria-label": params.showPasswordAriaLabelText | default("Show password"),
"hidden": {
'value': true,
Expand Down Expand Up @@ -81,7 +83,7 @@
'hint': params.hint,
'classes': "govuk-password-input__input govuk-js-password-input-input" ~ (" " ~ params.classes if params.classes),
'errorMessage': params.errorMessage,
'id': params.id,
'id': id,
'name': params.name,
'type': "password",
'spellcheck': false,
Expand Down
18 changes: 10 additions & 8 deletions govuk_frontend_jinja/templates/components/select/macro.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
{#- a record of other elements that we need to associate with the input using
aria-describedby – for example hints or error messages -#}
{% set describedBy = params.describedBy if params.describedBy else "" %}
{%- set id = params.id if params.id else params.name -%}

<div class="govuk-form-group {%- if params.errorMessage %} govuk-form-group--error{% endif %} {%- if params.formGroup and params.formGroup.classes %} {{ params.formGroup.classes }}{% endif %}"
{{- govukAttributes(params.formGroup.attributes if params.formGroup) }}>
{{ govukLabel({
Expand All @@ -15,10 +17,10 @@
'classes': params.label.classes,
'isPageHeading': params.label.isPageHeading,
'attributes': params.label.attributes,
'for': params.id
'for': id
}) | trim | indent(2) }}
{% if params.hint %}
{% set hintId = params.id ~ '-hint' %}
{% set hintId = id ~ '-hint' %}
{% set describedBy = describedBy ~ ' ' ~ hintId if describedBy else hintId %}
{{ govukHint({
'id': hintId,
Expand All @@ -29,7 +31,7 @@
}) | trim | indent(2) }}
{% endif %}
{% if params.errorMessage %}
{% set errorId = params.id ~ '-error' %}
{% set errorId = id ~ '-error' %}
{% set describedBy = describedBy ~ ' ' ~ errorId if describedBy else errorId %}
{{ govukErrorMessage({
'id': errorId,
Expand All @@ -44,13 +46,13 @@
{{ params.formGroup.beforeInput.html | safe | trim | indent(2) if params.formGroup and params.formGroup.beforeInput.html else params.formGroup.beforeInput.text }}
{% endif %}
<select class="govuk-select
{%- if params.classes %} {{ params.classes }}{% endif %}{%- if params.errorMessage %} govuk-select--error{% endif %}" id="{{ params.id }}" name="{{ params.name }}"
{%- if params.classes %} {{ params.classes }}{% endif %}{%- if params.errorMessage %} govuk-select--error{% endif %}" id="{{ id }}" name="{{ params.name }}"
{%- if params.disabled %} disabled{% endif %}
{%- if describedBy %} aria-describedby="{{ describedBy }}"{% endif %}
{{- govukAttributes(params.attributes) }}>
{% if 'items' in params and params['items'] | length %}
{% for item in params['items'] %}
{% if item %}
{% if item %}
{#- Allow selecting by text content (the value for an option when no value attribute is specified) #}
{%- set effectiveValue = item.value | default(item.text) %}
<option {%- if item.value is not undefined %} value="{{ item.value | lower }}"{% endif %}
Expand All @@ -59,9 +61,9 @@
{{- govukAttributes(item.attributes) }}>
{{- item.text -}}
</option>
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
</select>
{% if params.formGroup and params.formGroup.afterInput %}
{{ params.formGroup.afterInput.html | safe | trim | indent(2) if params.formGroup and params.formGroup.afterInput.html else params.formGroup.afterInput.text }}
Expand Down
10 changes: 6 additions & 4 deletions govuk_frontend_jinja/templates/components/textarea/macro.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
{#- a record of other elements that we need to associate with the input using
aria-describedby – for example hints or error messages -#}
{% set describedBy = params.describedBy if params.describedBy else "" %}
{%- set id = params.id if params.id else params.name -%}

<div class="govuk-form-group {%- if params.errorMessage %} govuk-form-group--error{% endif %} {%- if params.formGroup and params.formGroup.classes %} {{ params.formGroup.classes }}{% endif %}"
{{- govukAttributes(params.formGroup.attributes if params.formGroup) }}>
{{ govukLabel({
Expand All @@ -15,10 +17,10 @@
'classes': params.label.classes,
'isPageHeading': params.label.isPageHeading,
'attributes': params.label.attributes,
'for': params.id
'for': id
}) | trim | indent(2) }}
{% if params.hint %}
{% set hintId = params.id ~ '-hint' %}
{% set hintId = id ~ '-hint' %}
{% set describedBy = describedBy ~ ' ' ~ hintId if describedBy else hintId %}
{{ govukHint({
'id': hintId,
Expand All @@ -29,7 +31,7 @@
}) | trim | indent(2) }}
{% endif %}
{% if params.errorMessage %}
{% set errorId = params.id ~ '-error' %}
{% set errorId = id ~ '-error' %}
{% set describedBy = describedBy ~ ' ' ~ errorId if describedBy else errorId %}
{{ govukErrorMessage({
'id': errorId,
Expand All @@ -43,7 +45,7 @@
{% if params.formGroup and params.formGroup.beforeInput %}
{{ params.formGroup.beforeInput.html | safe | trim | indent(2) if params.formGroup and params.formGroup.beforeInput.html else params.formGroup.beforeInput.text }}
{% endif %}
<textarea class="govuk-textarea {%- if params.errorMessage %} govuk-textarea--error{% endif %} {%- if params.classes %} {{ params.classes }}{% endif %}" id="{{ params.id }}" name="{{ params.name }}" rows="{{ params.rows | default(5, true) }}"
<textarea class="govuk-textarea {%- if params.errorMessage %} govuk-textarea--error{% endif %} {%- if params.classes %} {{ params.classes }}{% endif %}" id="{{ id }}" name="{{ params.name }}" rows="{{ params.rows | default(5, true) }}"
{%- if (params.spellcheck is false) or (params.spellcheck is true) %} spellcheck="{{ params.spellcheck | lower }}"{% endif %}
{%- if params.disabled %} disabled{% endif %}
{%- if describedBy %} aria-describedby="{{ describedBy }}"{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion requirements-test-3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ blinker==1.9.0
# via flask
click==8.1.8
# via flask
flake8==7.1.1
flake8==7.1.2
# via -r requirements-test.in
flask==3.1.0
# via -r requirements-test.in
Expand Down
2 changes: 1 addition & 1 deletion requirements-test-3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ blinker==1.9.0
# via flask
click==8.1.8
# via flask
flake8==7.1.1
flake8==7.1.2
# via -r requirements-test.in
flask==3.1.0
# via -r requirements-test.in
Expand Down
2 changes: 1 addition & 1 deletion requirements-test-3.12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ blinker==1.9.0
# via flask
click==8.1.8
# via flask
flake8==7.1.1
flake8==7.1.2
# via -r requirements-test.in
flask==3.1.0
# via -r requirements-test.in
Expand Down
2 changes: 1 addition & 1 deletion requirements-test-3.13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ blinker==1.9.0
# via flask
click==8.1.8
# via flask
flake8==7.1.1
flake8==7.1.2
# via -r requirements-test.in
flask==3.1.0
# via -r requirements-test.in
Expand Down
4 changes: 2 additions & 2 deletions requirements-test-3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ blinker==1.9.0
# via flask
click==8.1.8
# via flask
flake8==7.1.1
flake8==7.1.2
# via -r requirements-test.in
flask==3.1.0
# via -r requirements-test.in
importlib-metadata==8.5.0
importlib-metadata==8.6.1
# via flask
itsdangerous==2.2.0
# via flask
Expand Down
Loading
Loading