-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3cc0b2
commit 4f1b888
Showing
1 changed file
with
76 additions
and
77 deletions.
There are no files selected for viewing
153 changes: 76 additions & 77 deletions
153
packages/govuk-frontend/src/govuk/components/summary-list/template.njk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,90 @@ | ||
{%- macro _actionLink(action, cardTitle) %} | ||
<a class="govuk-link {%- if action.classes %} {{ action.classes }}{% endif %}" href="{{ action.href }}" {%- for attribute, value in action.attributes %} {{ attribute }}="{{ value }}"{% endfor %}> | ||
{{- action.html | safe if action.html else action.text -}} | ||
{%- if action.visuallyHiddenText or cardTitle -%} | ||
<span class="govuk-visually-hidden"> | ||
{%- if action.visuallyHiddenText %} {{ action.visuallyHiddenText }}{% endif -%} | ||
{%- if cardTitle %} ({{ cardTitle.html | safe if cardTitle.html else cardTitle.text }}){% endif -%} | ||
</span> | ||
{%- endif -%} | ||
</a> | ||
<a class="govuk-link {%- if action.classes %} {{ action.classes }}{% endif %}" href="{{ action.href }}" {%- for attribute, value in action.attributes %} {{ attribute }}="{{ value }}"{% endfor %}> | ||
{{- action.html | safe if action.html else action.text -}} | ||
{%- if action.visuallyHiddenText or cardTitle -%} | ||
<span class="govuk-visually-hidden"> | ||
{%- if action.visuallyHiddenText %} {{ action.visuallyHiddenText }}{% endif -%} | ||
{%- if cardTitle %} ({{ cardTitle.html | safe if cardTitle.html else cardTitle.text }}){% endif -%} | ||
</span> | ||
{%- endif -%} | ||
</a> | ||
{% endmacro -%} | ||
|
||
{%- macro _summaryCard(params) %} | ||
{%- set headingLevel = params.title.headingLevel if params.title.headingLevel else 2 -%} | ||
{%- set headingLevel = params.title.headingLevel if params.title.headingLevel else 2 -%} | ||
|
||
<div class="govuk-summary-card {%- if params.classes %} {{ params.classes }}{% endif %}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}> | ||
<div class="govuk-summary-card__title-wrapper"> | ||
{%- if params.title -%} | ||
<h{{ headingLevel }} class="govuk-summary-card__title {%- if params.title.classes %} {{ params.title.classes }}{% endif %}"> | ||
{{- params.title.html | safe if params.title.html else params.title.text -}} | ||
</h{{ headingLevel }}> | ||
{%- endif -%} | ||
|
||
{%- if params.actions.items.length -%} | ||
{%- if params.actions.items.length == 1 -%} | ||
<div class="govuk-summary-card__actions {%- if params.actions.classes %} {{ params.actions.classes }}{% endif %}"> | ||
{{- _actionLink(params.actions.items[0], params.title) -}} | ||
</div> | ||
{%- else -%} | ||
<ul class="govuk-summary-card__actions {%- if params.actions.classes %} {{ params.actions.classes }}{% endif %}"> | ||
{%- for action in params.actions.items -%} | ||
<li class="govuk-summary-card__action"> | ||
{{- _actionLink(action, params.title) -}} | ||
</li> | ||
{%- endfor -%} | ||
</ul> | ||
{% endif -%} | ||
{%- endif -%} | ||
<div class="govuk-summary-card {%- if params.classes %} {{ params.classes }}{% endif %}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}> | ||
<div class="govuk-summary-card__title-wrapper"> | ||
{% if params.title %} | ||
<h{{ headingLevel }} class="govuk-summary-card__title {%- if params.title.classes %} {{ params.title.classes }}{% endif %}"> | ||
{{ params.title.html | safe | trim | indent(6) if params.title.html else params.title.text }} | ||
</h{{ headingLevel }}> | ||
{% endif %} | ||
{% if params.actions.items.length %} | ||
{% if params.actions.items.length == 1 %} | ||
<div class="govuk-summary-card__actions {%- if params.actions.classes %} {{ params.actions.classes }}{% endif %}"> | ||
{{ _actionLink(params.actions.items[0], params.title) | safe | trim | indent(6) }} | ||
</div> | ||
{% else %} | ||
<ul class="govuk-summary-card__actions {%- if params.actions.classes %} {{ params.actions.classes }}{% endif %}"> | ||
{% for action in params.actions.items %} | ||
<li class="govuk-summary-card__action"> | ||
{{ _actionLink(action, params.title) | safe | trim | indent(10) }} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
{% endif %} | ||
</div> | ||
|
||
<div class="govuk-summary-card__content"> | ||
{{- caller() -}} | ||
</div> | ||
<div class="govuk-summary-card__content"> | ||
{{ caller() | trim }} | ||
</div> | ||
{% endmacro -%} | ||
</div> | ||
{% endmacro %} | ||
|
||
{# Determine if we need 2 or 3 columns #} | ||
{% set anyRowHasActions = false %} | ||
{#- Determine if we need 2 or 3 columns #} | ||
{%- set anyRowHasActions = false %} | ||
{% for row in params.rows %} | ||
{% set anyRowHasActions = true if row.actions.items | length else anyRowHasActions %} | ||
{% endfor -%} | ||
{% endfor %} | ||
|
||
{%- set summaryList -%} | ||
<dl class="govuk-summary-list {%- if params.classes %} {{ params.classes }}{% endif %}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}> | ||
{% for row in params.rows %} | ||
{% if row %} | ||
<div class="govuk-summary-list__row {%- if anyRowHasActions and not row.actions.items %} govuk-summary-list__row--no-actions{% endif %} {%- if row.classes %} {{ row.classes }}{% endif %}"> | ||
<dt class="govuk-summary-list__key {%- if row.key.classes %} {{ row.key.classes }}{% endif %}"> | ||
{{ row.key.html | indent(4 if params.card else 0) | safe if row.key.html else row.key.text }} | ||
</dt> | ||
<dd class="govuk-summary-list__value {%- if row.value.classes %} {{ row.value.classes }}{% endif %}"> | ||
{{ row.value.html | indent(12 if params.card else 8) | safe | trim if row.value.html else row.value.text }} | ||
</dd> | ||
{% if row.actions.items.length %} | ||
<dd class="govuk-summary-list__actions {%- if row.actions.classes %} {{ row.actions.classes }}{% endif %}"> | ||
{% if row.actions.items.length == 1 %} | ||
{{ _actionLink(row.actions.items[0], params.card.title) | indent(16 if params.card else 12) | trim }} | ||
{% else %} | ||
<ul class="govuk-summary-list__actions-list"> | ||
{%- for action in row.actions.items -%} | ||
<li class="govuk-summary-list__actions-list-item"> | ||
{{- _actionLink(action, params.card.title) | indent(22 if params.card else 18) | trim -}} | ||
</li> | ||
{%- endfor -%} | ||
</ul> | ||
{% endif %} | ||
</dd> | ||
{% endif %} | ||
</div> | ||
{%- set summaryList %} | ||
<dl class="govuk-summary-list {%- if params.classes %} {{ params.classes }}{% endif %}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}> | ||
{% for row in params.rows %} | ||
{% if row %} | ||
<div class="govuk-summary-list__row {%- if anyRowHasActions and not row.actions.items %} govuk-summary-list__row--no-actions{% endif %} {%- if row.classes %} {{ row.classes }}{% endif %}"> | ||
<dt class="govuk-summary-list__key {%- if row.key.classes %} {{ row.key.classes }}{% endif %}"> | ||
{{ row.key.html | safe | trim | indent(6) if row.key.html else row.key.text }} | ||
</dt> | ||
<dd class="govuk-summary-list__value {%- if row.value.classes %} {{ row.value.classes }}{% endif %}"> | ||
{{ row.value.html | safe | trim | indent(6) if row.value.html else row.value.text }} | ||
</dd> | ||
{% if row.actions.items.length %} | ||
<dd class="govuk-summary-list__actions {%- if row.actions.classes %} {{ row.actions.classes }}{% endif %}"> | ||
{% if row.actions.items.length == 1 %} | ||
{{ _actionLink(row.actions.items[0], params.card.title) | safe | trim | indent(6) }} | ||
{% else %} | ||
<ul class="govuk-summary-list__actions-list"> | ||
{% for action in row.actions.items %} | ||
<li class="govuk-summary-list__actions-list-item"> | ||
{{ _actionLink(action, params.card.title) | safe | trim | indent(10) }} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
{% endfor %} | ||
</dl> | ||
{%- endset %} | ||
</dd> | ||
{% endif %} | ||
</div> | ||
{% endif %} | ||
{% endfor %} | ||
</dl> | ||
{% endset %} | ||
|
||
{%- if params.card -%} | ||
{% call _summaryCard(params.card) -%} | ||
{{ summaryList | safe }} | ||
{%- endcall %} | ||
{%- else -%} | ||
{{ summaryList | safe }} | ||
{%- endif %} | ||
{%- if params.card %} | ||
{% call _summaryCard(params.card) %} | ||
{{ summaryList | safe | trim | indent(4) }} | ||
{% endcall %} | ||
{% else %} | ||
{{ summaryList | safe | trim }} | ||
{% endif %} |