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

Re-Sync with the upstream project maintained by HM Land Registry #13

Merged
merged 1 commit into from
Jun 25, 2024
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
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ 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/tim-s-ccs/ccs-govuk-frontend-jinja/compare/1.0.0...main)
## [Unreleased](https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/compare/1.2.0...main)

## [1.1.0](https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/releases/tag/1.0.0) - 20/05/2024
## [1.2.0](https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/releases/tag/1.2.0) - 25/06/2024

### Changed

- [Re-Sync with the upstream project maintained by HM Land Registry](https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/pull/13)

## [1.1.0](https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/releases/tag/1.1.0) - 20/05/2024

### Added

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

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

**This is a fork of [GOV.UK Frontend Jinja Macros](https://github.com/LandRegistry/govuk-frontend-jinja) which has not been updated beyond GOV.UK Frontend v5.1. This is for use in the Digital Marketplace until it starts to get updated again.**
Expand All @@ -17,7 +17,8 @@ The following table shows the version of CCS GOV.UK Frontend Jinja that you shou

| CCS GOV.UK Frontend Jinja Version | Target GOV.UK Frontend Version |
| ----------------------------- | ------------------------------ |
| [1.1.0](https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/releases/tag/1.1.0) | [5.3.1](https://github.com/alphagov/govuk-frontend/releases/tag/v5.4.0) |
| [1.2.0](https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/releases/tag/1.2.0) | [5.4.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.4.0) |
| [1.1.0](https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/releases/tag/1.1.0) | [5.4.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.4.0) |
| [1.0.0](https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/releases/tag/1.0.0) | [5.3.1](https://github.com/alphagov/govuk-frontend/releases/tag/v5.3.1) |

Any other versions of GOV.UK Frontend not shown above _may_ still be compatible, but have not been specifically tested and verified.
Expand Down
2 changes: 1 addition & 1 deletion govuk_frontend_jinja/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.1.1"
__version__ = "1.2.0"
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% macro govukBackLink(params) %}
{% from "govuk_frontend_jinja/macros/attributes.html" import govukAttributes %}
{% from "govuk_frontend_jinja/macros/attributes.html" import govukAttributes -%}

<a href="{% if params.href %}{{ params.href }}{% else %}#{% endif %}" class="govuk-back-link {%- if params.classes %} {{ params.classes }}{% endif %}"
{{- govukAttributes(params.attributes) }}>
{{ (params.html | safe if params.html else (params.text if params.text else 'Back')) }}
{{- params.html | safe if params.html else (params.text if params.text else "Back") -}}
</a>
{% endmacro %}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{% macro govukBreadcrumbs(params) %}
{% from "govuk_frontend_jinja/macros/attributes.html" import govukAttributes %}

{# Set classes for this component #}
{#- Set classes for this component #}
{%- set classNames = "govuk-breadcrumbs" -%}

{% if params.classes %}
{% set classNames = classNames + " " + params.classes %}
{% set classNames = classNames ~ " " ~ params.classes %}
{% endif -%}

{% if params.collapseOnMobile %}
{% set classNames = classNames + " govuk-breadcrumbs--collapse-on-mobile" %}
{% set classNames = classNames ~ " govuk-breadcrumbs--collapse-on-mobile" %}
{% endif -%}

<div class="{{ classNames }}" {{- govukAttributes(params.attributes) }}>
Expand Down
8 changes: 4 additions & 4 deletions govuk_frontend_jinja/templates/components/button/macro.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{% macro govukButton(params) %}
{% from "govuk_frontend_jinja/macros/attributes.html" import govukAttributes %}

{# Set classes for this component #}
{#- Set classes for this component #}
{%- set classNames = "govuk-button" -%}

{%- if params.classes %}
{% set classNames = classNames + " " + params.classes %}
{% set classNames = classNames ~ " " ~ params.classes %}
{% endif %}

{%- if params.isStartButton %}
{% set classNames = classNames + " govuk-button--start" %}
{% set classNames = classNames ~ " govuk-button--start" %}
{% endif %}

{#- Determine type of element to use, if not explicitly set #}
{%- if params.element %}
{% set element = params.element %}
{% set element = params.element | lower %}
{% else %}
{% if params.href %}
{% set element = 'a' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@
#}
{%- set hasNoLimit = (not params.maxwords and not params.maxlength) -%}
{%- 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 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 countMessageHtml %}
{{ govukHint({
"text": textareaDescriptionTextNoLimit,
"id": params.id + '-info',
"classes": 'govuk-character-count__message' + (' ' + params.countMessage.classes if params.countMessage and params.countMessage.classes else '')
'text': textareaDescriptionTextNoLimit,
'id': params.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 %}
{{- params.formGroup.afterInput.html | safe | trim if params.formGroup.afterInput.html else params.formGroup.afterInput.text }}
{{- params.formGroup.afterInput.html | safe | trim if params.formGroup and params.formGroup.afterInput.html else params.formGroup.afterInput.text }}
{% endif -%}
{% endset -%}

{%- set attributesHtml %}
{{- govukAttributes({
"data-module": "govuk-character-count",
"data-maxlength": {
"value": params.maxlength,
"optional": true
'value': params.maxlength,
'optional': true
},
"data-threshold": {
"value": params.threshold,
"optional": true
'value': params.threshold,
'optional': true
},
"data-maxwords": {
"value": params.maxwords,
"optional": true
'value': params.maxwords,
'optional': true
}
}) -}}

Expand Down Expand Up @@ -87,28 +87,28 @@
{% endset -%}

{#- Append form group attributes onto attributes set above #}
{%- if params.formGroup %}
{%- for name, value in (params.formGroup.attributes if params.formGroup and params.formGroup.attributes else {}).items() %}
{% set attributesHtml = '{} {}="{}"'.format(attributesHtml, name | escape, options.value | escape) %}
{%- if params.formGroup -%}
{%- for name, value in params.formGroup.attributes if params.formGroup %}
{% set attributesHtml = attributesHtml ~ " " ~ name | escape ~ '="' ~ value | escape ~ '"' %}
{% endfor -%}
{% endif -%}
{%- endif -%}

{{ govukTextarea({
'id': params.id,
'name': params.name,
'describedBy': params.id + '-info',
'describedBy': params.id ~ '-info',
'rows': params.rows,
'spellcheck': params.spellcheck,
'value': params.value,
'formGroup': {
'classes': 'govuk-character-count' + (' ' + params.formGroup.classes if params.formGroup and params.formGroup.classes else ''),
'classes': 'govuk-character-count' ~ (' ' ~ params.formGroup.classes if params.formGroup and params.formGroup.classes),
'attributes': attributesHtml,
'beforeInput': params.formGroup.beforeInput if params.formGroup else null,
'beforeInput': params.formGroup.beforeInput if params.fromGroup,
'afterInput': {
'html': countMessageHtml
}
},
'classes': 'govuk-js-character-count' + (' ' + params.classes if params.classes else ''),
'classes': 'govuk-js-character-count' ~ (' ' ~ params.classes if params.classes),
'label': {
'html': params.label.html,
'text': params.label.text,
Expand Down
30 changes: 15 additions & 15 deletions govuk_frontend_jinja/templates/components/checkboxes/macro.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
{%- macro _checkboxItem(params, item, index) %}
{#- If the user explicitly sets an id, use this instead of the regular idPrefix -#}
{#- The first id should not have a number suffix so it's easy to link to from the error summary component -#}
{% set itemId = item.id if item.id else idPrefix + ("-" ~ index if index > 1 else "") %}
{% set itemId = item.id if item.id else idPrefix ~ ("-" ~ index if index > 1 else "") %}
{% set itemName = item.name if item.name else params.name %}
{% set conditionalId = "conditional-" + itemId %}
{% set conditionalId = "conditional-" ~ itemId %}
{%- if item.divider %}
<div class="govuk-checkboxes__divider">{{ item.divider }}</div>
{% else %}
{% set isChecked = item.checked | default((item.value in params.get('values', []) and item.checked != false) if params.values else false, true) %}
{% set isChecked = item.checked | default((item.value in params.get('values', []) and item.checked is not false) if params.values else false, true) %}
{% set hasHint = true if item.hint and (item.hint.text or item.hint.html) %}
{% set itemHintId = itemId + "-item-hint" if hasHint else "" %}
{% set itemHintId = itemId ~ "-item-hint" if hasHint else "" %}
{% set itemDescribedBy = ns.describedBy if not hasFieldset else "" %}
{% set itemDescribedBy = (itemDescribedBy + " " + itemHintId) | trim %}
{% set itemDescribedBy = (itemDescribedBy ~ " " ~ itemHintId) | trim %}
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="{{ itemId }}" name="{{ itemName }}" type="checkbox" value="{{ item.value }}"
{{-" checked" if isChecked }}
Expand All @@ -46,15 +46,15 @@
{{ govukLabel({
'html': item.html,
'text': item.text,
'classes': 'govuk-checkboxes__label' + (' ' + item.label.classes if item.label and item.label.classes else ''),
'classes': 'govuk-checkboxes__label' ~ (' ' ~ item.label.classes if item.label and item.label.classes else ""),
'attributes': item.label.attributes if item.label,
'for': itemId
}) | trim | indent(6) }}
{% if hasHint %}
{{ govukHint({
'id': itemHintId,
'classes': 'govuk-checkboxes__hint' + (' ' + item.hint.classes if item.hint.classes else ''),
'attributes': item.hint.attributes,
'classes': 'govuk-checkboxes__hint' ~ (' ' ~ item.hint.classes if item.hint and item.hint.classes else ""),
'attributes': item.hint.attributes if item.hint,
'html': item.hint.html,
'text': item.hint.text
}) | trim | indent(6) }}
Expand All @@ -71,8 +71,8 @@
{#- Capture the HTML so we can optionally nest it in a fieldset -#}
{% set innerHtml %}
{% if params.hint %}
{% set hintId = idPrefix + '-hint' %}
{% set ns.describedBy = ns.describedBy + ' ' + hintId if ns.describedBy else hintId %}
{% set hintId = idPrefix ~ '-hint' %}
{% set ns.describedBy = ns.describedBy ~ ' ' ~ hintId if ns.describedBy else hintId %}
{{ govukHint({
'id': hintId,
'classes': params.hint.classes,
Expand All @@ -82,8 +82,8 @@
}) | trim | indent(2) }}
{% endif %}
{% if params.errorMessage %}
{% set errorId = idPrefix + '-error' %}
{% set ns.describedBy = ns.describedBy + ' ' + errorId if ns.describedBy else errorId %}
{% set errorId = idPrefix ~ '-error' %}
{% set ns.describedBy = ns.describedBy ~ ' ' ~ errorId if ns.describedBy else errorId %}
{{ govukErrorMessage({
'id': errorId,
'classes': params.errorMessage.classes,
Expand All @@ -96,21 +96,21 @@
<div class="govuk-checkboxes {%- if params.classes %} {{ params.classes }}{% endif %}"
{{- govukAttributes(params.attributes) }} data-module="govuk-checkboxes">
{% if params.formGroup and params.formGroup.beforeInputs %}
{{ params.formGroup.beforeInputs.html | safe | trim | indent(4) if params.formGroup.beforeInputs.html else params.formGroup.beforeInputs.text }}
{{ params.formGroup.beforeInputs.html | safe | trim | indent(4) if params.formGroup and params.formGroup.beforeInputs.html else params.formGroup.beforeInputs.text }}
{% endif %}
{% for item in params['items'] %}
{% if item %}
{{- _checkboxItem(params, item, loop.index) -}}
{% endif %}
{% endfor %}
{% if params.formGroup and params.formGroup.afterInputs %}
{{ params.formGroup.afterInputs.html | safe | trim | indent(4) if params.formGroup.afterInputs.html else params.formGroup.afterInputs.text }}
{{ params.formGroup.afterInputs.html | safe | trim | indent(4) if params.formGroup and params.formGroup.afterInputs.html else params.formGroup.afterInputs.text }}
{% endif %}
</div>
{% endset -%}

<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 else {}) }}>
{{- govukAttributes(params.formGroup.attributes if params.formGroup) }}>
{% if hasFieldset %}
{{ govukFieldset({
'describedBy': ns.describedBy,
Expand Down
90 changes: 45 additions & 45 deletions govuk_frontend_jinja/templates/components/cookie-banner/macro.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,57 @@
{% from "govuk_frontend_jinja/components/button/macro.html" import govukButton -%}

<div class="govuk-cookie-banner {%- if params.classes %} {{ params.classes }}{% endif %}" data-nosnippet role="region" aria-label="{{ params.ariaLabel | default("Cookie banner", true) }}"
{{- govukAttributes(params.attributes) }}
{%- if params.hidden %} hidden{% endif %}>
{%- for message in params.messages %}
<div class="govuk-cookie-banner__message {%- if message.classes %} {{ message.classes }}{% endif %} govuk-width-container" {%- if message.role %} role="{{ message.role }}"{% endif %}
{{- govukAttributes(message.attributes) -}}
{%- if message.hidden %} hidden{% endif %}>
{%- if params.hidden %} hidden{% endif %}
{{- govukAttributes(params.attributes) }}>
{% for message in params.messages %}
<div class="govuk-cookie-banner__message {%- if message.classes %} {{ message.classes }}{% endif %} govuk-width-container" {%- if message.role %} role="{{ message.role }}"{% endif %}
{{- govukAttributes(message.attributes) -}}
{%- if message.hidden %} hidden{% endif %}>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{% if message.headingHtml or message.headingText %}
<h2 class="govuk-cookie-banner__heading govuk-heading-m">
{{ message.headingHtml | safe | trim | indent(10) if message.headingHtml else message.headingText }}
</h2>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{% if message.headingHtml or message.headingText %}
<h2 class="govuk-cookie-banner__heading govuk-heading-m">
{{ message.headingHtml | safe | trim | indent(10) if message.headingHtml else message.headingText }}
</h2>
{% endif %}
<div class="govuk-cookie-banner__content">
{% if message.html %}
{{ message.html | safe | trim | indent(10) }}
{% elif message.text %}
<p class="govuk-body">{{ message.text }}</p>
{% endif %}

<div class="govuk-cookie-banner__content">
{% if message.html %}
{{ message.html | safe | trim | indent(10) }}
{% elif message.text %}
<p class="govuk-body">{{ message.text }}</p>
{% endif %}
</div>
</div>
</div>
</div>

{% if message.actions %}
<div class="govuk-button-group">
{% for action in message.actions %}
{% set buttonHtml -%}
{% if not action.href or action.type == "button" %}
{{ govukButton({
"text": action.text,
"type": action.type if action.type else "button",
"name": action.name,
"value": action.value,
"classes": action.classes,
"href": action.href,
"attributes": action.attributes
}) }}
{% else %}
<a class="govuk-link {%- if action.classes %} {{ action.classes }}{% endif %}" href="{{ action.href }}"
{{- govukAttributes(action.attributes) }}>
{{- action.text -}}
</a>
{% endif %}
{%- endset %}
{{ buttonHtml | safe | trim | indent(6) }}
{% endfor %}
</div>
{% endif %}
{% if message.actions %}
<div class="govuk-button-group">
{% for action in message.actions %}
{% set buttonHtml -%}
{% if not action.href or action.type == "button" %}
{{ govukButton({
"text": action.text,
"type": action.type if action.type else "button",
"name": action.name,
"value": action.value,
"classes": action.classes,
"href": action.href,
"attributes": action.attributes
}) }}
{% else %}
<a class="govuk-link {%- if action.classes %} {{ action.classes }}{% endif %}" href="{{ action.href }}"
{{- govukAttributes(action.attributes) }}>
{{- action.text -}}
</a>
{% endif %}
{%- endset %}
{{ buttonHtml | safe | trim | indent(6) }}
{% endfor %}
</div>
{% endif %}

</div>
{% endfor %}
</div>
{% endmacro %}
Loading
Loading