{% from "components/icon.html" import Icon %} {% macro Alert(title, message=None, actions=None, level='info', fragment=None) -%} {% set role = 'alertdialog' if actions else 'alert' %} {% set levels = { 'warning': { 'icon': 'alert', 'tone': 'assertive' }, 'error': { 'icon': 'alert', 'tone': 'assertive' }, 'info': { 'icon': 'info', 'tone': 'polite' }, 'success': { 'icon': 'ok', 'tone': 'polite' } } %}
{{ Icon(levels.get(level).get('icon'), classes='alert__icon icon--large') }}

{{title}}

{% if message %}
{{ message | safe }}
{% endif %} {% if caller %}
{{ caller() }}
{% endif %} {% if fragment %}
{% include fragment %}
{% endif %} {% if actions %}
{% if actions is string %} {{ actions | safe }} {% elif actions is iterable %} {% for action in actions %} {% if 'icon' in action %}{{ Icon(action["icon"]) }}{% endif %} {{ action["label"] }} {% endfor %} {% endif %}
{% endif %}
{%- endmacro %}