{#
/**
 * @file
 * Template for a Bootstrap 5 Alert.
 *
 * Available variables:
 * - attributes: HTML attributes for the alert wrapper element.
 * - variant: Bootstrap color variant (primary, secondary, success, etc.).
 * - heading: Optional heading text displayed above the alert body.
 * - heading_level: HTML heading level for the alert heading (h2-h6).
 * - dismissible: (boolean) Add a close button to dismiss the alert.
 * - custom_class: Additional CSS classes for the alert element.
 *
 * Available slots:
 * - alert_body: The alert message content.
 *
 * @ingroup themeable
 */
#}

{% set variant = variant|default('primary') %}
{% set heading_level = heading_level|default('h4') %}

{% set classes = [
  'alert',
  'alert-' ~ variant,
  dismissible ? 'alert-dismissible fade show' : '',
  custom_class|default(''),
]|filter(v => v) %}

<div{{ attributes.addClass(classes) }} role="alert">

  {% if heading %}
    <{{ heading_level }} class="alert-heading">{{ heading }}</{{ heading_level }}>
  {% endif %}

  {% block alert_body %}{% endblock %}

  {% if dismissible %}
    <button
      type="button"
      class="btn-close"
      data-bs-dismiss="alert"
      aria-label="Close"
    ></button>
  {% endif %}

</div>
