Merge pull request #3593 from alphagov/fix-link-and-button-text-across-pages

Fix link and button text across pages
This commit is contained in:
Tom Byers
2020-09-01 15:11:09 +01:00
committed by GitHub
15 changed files with 164 additions and 131 deletions

View File

@@ -1,7 +1,7 @@
{% from "components/form.html" import form_wrapper %}
{% from "components/button/macro.njk" import govukButton %}
{% macro banner(body, type=None, with_tick=False, delete_button=None, subhead=None, context=None, action=None, id=None) %}
{% macro banner(body, type=None, with_tick=False, delete_button=None, subhead=None, context=None, action=None, id=None, thing=None) %}
<div
class='banner{% if type %}-{{ type }}{% endif %}{% if with_tick %}-with-tick{% endif %}'
{% if type == 'dangerous' %}
@@ -25,7 +25,8 @@
{% call form_wrapper(action=action) %}
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
{{ govukButton({
"text": delete_button,
"text": "" if thing else delete_button,
"html": delete_button + "<span class=\"govuk-visually-hidden\"> " + thing + "</span>" if thing else "",
"name": "delete",
"classes": "govuk-button--warning govuk-!-margin-top-2",
}) }}
@@ -34,6 +35,6 @@
</div>
{% endmacro %}
{% macro banner_wrapper(type=None, with_tick=False, delete_button=None, subhead=None, action=None, id=None) %}
{{ banner(caller()|safe, type=type, with_tick=with_tick, delete_button=delete_button, subhead=subhead, action=action, id=id) }}
{% macro banner_wrapper(type=None, with_tick=False, delete_button=None, subhead=None, action=None, id=None, thing=None) %}
{{ banner(caller()|safe, type=type, with_tick=with_tick, delete_button=delete_button, subhead=subhead, action=action, id=id, thing=thing) }}
{% endmacro %}

View File

@@ -19,7 +19,7 @@
<p class="notify-cookie-banner__confirmation-message govuk-body">
You can <a class="govuk-link" href="/cookies">change your cookie settings</a> at any time.
</p>
<button class="notify-cookie-banner__hide-button govuk-link" data-hide-cookie-banner="true" role="link">Hide</button>
<button class="notify-cookie-banner__hide-button govuk-link" data-hide-cookie-banner="true" role="link">Hide<span class="govuk-visually-hidden"> cookies message</span></button>
</div>
</div>
{% endmacro %}

View File

@@ -4,6 +4,7 @@
button_text=None,
button_name=None,
button_value=None,
button_text_hidden_suffix=None,
destructive=False,
secondary_link=False,
secondary_link_text=None,
@@ -20,6 +21,11 @@
{% if centered_button %}{% set _ = button_data.update({"classes": "page-footer__button--centred"}) %}{% endif %}
{% if button_name %}{% set _ = button_data.update({"name": button_name}) %}{% endif %}
{% if button_value %}{% set _ = button_data.update({"value": button_value}) %}{% endif %}
{% if button_text_hidden_suffix %}
{% set _ = button_data.update({
"text": "", "html": button_text + "<span class=\"govuk-visually-hidden\"> " + button_text_hidden_suffix + "</span>"
}) %}
{% endif %}
{{ govukButton(button_data) }}

View File

@@ -121,10 +121,13 @@
{% endcall %}
{%- endmacro %}
{% macro edit_field(text, link, permissions=[]) -%}
{% macro edit_field(text, link, permissions=[], suffix=None) -%}
{% call field(align='right') %}
{% if not permissions or current_user.has_permissions(*permissions) %}
<a class="govuk-link govuk-link--no-visited-state" href="{{ link }}">{{ text }}</a>
<a class="govuk-link govuk-link--no-visited-state" href="{{ link }}">
{{ text }}
{%- if suffix %}<span class="govuk-visually-hidden"> {{ suffix }}</span>{% endif -%}
</a>
{% endif %}
{% endcall %}
{%- endmacro %}