{#
Global messages template

https://getbootstrap.com/docs/5.2/components/alerts

*Type:
The template provides an easy way to display messages in the storefront. The following types are supported:

* primary
* secondary
* danger (red)
* success (green)
* warning (yellow)
* info (blue)
* light (white)
* dark (dark gray)

    {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
        type:"primary",
        content:"Primary Lorem ipsum dolor"
    } %}

*Icons:
Icons are shown by default. To hide the icon within the alert, set the value of "icon" to false:

    {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
        type:"primary",
        content:"Primary Lorem ipsum dolor",
        icon: false
    } %}

*IconCache:
IconCache is used by system settings. To avoid using the icon cache regardless of the system settings (e.g. for an icon rendered in an invisible area like <noscript>), set "iconCache" to false:

    {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
        type:"primary",
        content:"Primary Lorem ipsum dolor",
        iconCache: false
    } %}


*Message Content:
The component requires the parameters ```content``` or ```list``` to display a message. If no ```type``` is defined it
will use the fallback option (success).

    {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
        type:"primary",
        content:"Primary Lorem ipsum dolor"
    } %}

*Message List:
If you need to display a bunch of messages (for example error messages in the registration), you can pass an array
of messages to the template using the parameter ```list```:

     {% set list1 = [
        'Error message 1',
        'Error message 2',
        'Error message 3'
    ] %}

    {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
        type:"secondary",
        list: list1
    } %}

*Heading:
To display a heading, use "heading".

    {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
        type:"primary",
        content:"Primary Lorem ipsum dolor",
        heading: "Test Heading"
    } %}

*Dismissible Button:
To display a dismissible button set the value of "dismissible" to true.

    {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
        type:"primary",
        content:"Primary Lorem ipsum dolor",
        dismissible: true
    } %}

#}

{% block utilities_alert %}
    <div role="alert"
         aria-live="polite"
         {# @deprecated tag:v6.7.0 - Class `alert-has-icon` will be removed. Use helper classes `d-flex align-items-center` directly in the template like documented by Bootstrap. #}
         class="alert {% if type %}alert-{{ type }}{% endif %}{% if dismissible %} alert-dismissible fade show{% endif %}{% if icon != 'error' %} {% if feature('ACCESSIBILITY_TWEAKS') %}d-flex align-items-center{% else %}alert-has-icon{% endif %}{% endif %}">
        {% block utilities_alert_icon %}
            {% if icon != 'false' %}
                {% set iconCacheSystem = config('core.storefrontSettings.iconCache') %}
                {% if iconCache === false and iconCacheSystem === true %}
                    {{ sw_icon_cache_disable() }}
                {% endif %}
                {% if type == 'danger' %}
                    {% sw_icon 'blocked' style { ariaHidden: true } %}
                {% elseif type == 'warning' %}
                    {% sw_icon 'warning' style { ariaHidden: true } %}
                {% elseif type == 'info' %}
                    {% sw_icon 'info' style { ariaHidden: true } %}
                {% elseif type == 'success' %}
                    {% sw_icon 'checkmark-circle' style { ariaHidden: true } %}
                {% else %}
                    {% sw_icon 'alert' style { ariaHidden: true } %}
                {% endif %}
                {% if iconCache == false and iconCacheSystem === true %}
                    {{ sw_icon_cache_enable() }}
                {% endif %}
            {% endif %}
        {% endblock %}

        {% block utilities_alert_content_container %}
            <div class="alert-content-container">
                {% block utilities_alert_heading %}
                    {% if heading %}
                        <div class="alert-heading h5">
                            {{ heading }}
                        </div>
                    {% endif %}
                {% endblock %}

                {% block utilities_alert_content %}
                    {# @deprecated tag:v6.7.0 - The inner container `alert-content` will be removed. #}
                    {% if not feature('v6.7.0.0') %}<div class="alert-content">{% endif %}
                        {% if list|length > 1 %}
                            <ul class="alert-list">
                                {% for entry in list %}
                                    <li>{{ entry|sw_sanitize }}</li>
                                {% endfor %}
                            </ul>
                        {% elseif list|length == 1 %}
                            {% for entry in list %}
                                {{ entry|sw_sanitize }}
                            {% endfor %}
                        {% else %}
                            {{ content|sw_sanitize }}
                        {% endif %}
                    {# @deprecated tag:v6.7.0 - The inner container `alert-content` will be removed. #}
                    {% if not feature('v6.7.0.0') %}</div>{% endif %}
                {% endblock %}

                {% block utilities_alert_dismissible %}
                    {% if dismissible %}
                        <button type="button"
                                class="btn-close"
                                data-bs-dismiss="alert"
                                aria-label="Close">
                            <span aria-hidden="true"></span>
                        </button>
                    {% endif %}
                {% endblock %}
            </div>
        {% endblock %}
    </div>
{% endblock %}
