Files
notifications-admin/app/templates/components/banner.html

41 lines
1.6 KiB
HTML

{% from "components/form.html" import form_wrapper %}
{% from "components/components/button/macro.njk" import usaButton %}
{% macro banner(body, type=None, with_tick=False, delete_button=None, subhead=None, context=None, action=None, id=None, thing=None) %}
<div
class="usa-alert {% if type == 'dangerous' %}usa-alert--error{% else %}usa-alert--success{% endif %} banner{% if type %}-{{ type }}{% endif %}{% if with_tick %}-with-tick{% endif %}"
{% if id %}
id={{ id }}
{% endif %}
>
<div class="usa-alert__body">
{% if subhead -%}
<h3 class="usa-alert__heading">{{ subhead }}</h3>
{%- endif -%}
<p class="usa-alert__text">
{{ body }}
</p>
{% if context %}
<p class="usa-alert__text">
{{ context }}
</p>
{% endif %}
{% if delete_button %}
{% call form_wrapper(action=action) %}
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
{{ usaButton({
"text": "" if thing else delete_button,
"html": delete_button + "<span class=\"usa-sr-only\"> '" + thing + "'</span>" if thing else "",
"name": "delete",
"classes": "margin-top-2 usa-button--secondary",
}) }}
{% endcall %}
{% endif %}
</div>
</div>
{% endmacro %}
{% 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 %}