Skip to content

Commit

Permalink
checkboxes updates
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-shaw committed Feb 8, 2024
1 parent 5002148 commit 47bfceb
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions govuk_frontend_jinja/templates/components/checkboxes/macro.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{% endif %}

{#- fieldset is false by default -#}
{% set hasFieldset = True if params.fieldset else False %}
{% set hasFieldset = true if params.fieldset else false %}

{#- Capture the HTML so we can optionally nest it in a fieldset -#}
{% set innerHtml %}
Expand All @@ -31,7 +31,7 @@
'attributes': params.hint.attributes,
'html': params.hint.html,
'text': params.hint.text
}) | indent(2) | trim }}
}) | trim | indent(2) }}
{% endif %}
{% if params.errorMessage %}
{% set errorId = idPrefix + '-error' %}
Expand All @@ -43,7 +43,7 @@
'html': params.errorMessage.html,
'text': params.errorMessage.text,
'visuallyHiddenText': params.errorMessage.visuallyHiddenText
}) | indent(2) | trim }}
}) | trim | indent(2) }}
{% endif %}
<div class="govuk-checkboxes {%- if params.classes %} {{ params.classes }}{% endif %}"
{%- for attribute, value in (params.attributes.items() if params.attributes else {}.items()) %} {{ attribute }}="{{ value }}"{% endfor %} data-module="govuk-checkboxes">
Expand All @@ -65,8 +65,8 @@
{%- 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 hasHint = True if item.hint and (item.hint.text or item.hint.html) %}
{% set isChecked = item.checked | default((item.value in params.get('values', []) and item.checked != false) if params.values else false, true) %}
{% set hasHint = true if item.hint and (item.hint.text or item.hint.html) %}
{% set itemHintId = id + "-item-hint" if hasHint else "" %}
{% set itemDescribedBy = ns.describedBy if not hasFieldset else "" %}
{% set itemDescribedBy = (itemDescribedBy + " " + itemHintId) | trim %}
Expand All @@ -84,15 +84,15 @@
'classes': 'govuk-checkboxes__label' + (' ' + item.label.classes if item.label and item.label.classes else ''),
'attributes': item.label.attributes if item.label,
'for': id
}) | indent(6) | trim }}
}) | trim | indent(6) }}
{% if hasHint %}
{{ govukHint({
'id': itemHintId,
'classes': 'govuk-checkboxes__hint' + (' ' + item.hint.classes if item.hint.classes else ''),
'attributes': item.hint.attributes,
'html': item.hint.html,
'text': item.hint.text
}) | indent(6) | trim }}
}) | trim | indent(6) }}
{% endif %}
</div>
{% if item.conditional and item.conditional.html %}
Expand All @@ -106,18 +106,17 @@
</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 %}">
{% if params.fieldset %}
{% call govukFieldset({
<div class="govuk-form-group {%- if params.errorMessage %} govuk-form-group--error{% endif %} {%- if params.formGroup and params.formGroup.classes %} {{ params.formGroup.classes }}{% endif %}" {%- for attribute, value in (params.formGroup.attributes.items() if params.formGroup and params.formGroup.attributes else {}.items()) %} {{ attribute }}="{{ value }}"{% endfor %}>
{% if hasFieldset %}
{{ govukFieldset({
'describedBy': ns.describedBy,
'classes': params.fieldset.classes,
'attributes': params.fieldset.attributes,
'legend': params.fieldset.legend
}) %}
{{ innerHtml | trim | safe }}
{% endcall %}
'legend': params.fieldset.legend,
'html': innerHtml | trim
}) | trim | indent(2) }}
{% else %}
{{ innerHtml | trim | safe }}
{{ innerHtml | safe | trim }}
{% endif %}
</div>
{% endmacro %}

0 comments on commit 47bfceb

Please sign in to comment.