bootstrap_italia-8.x-0.x-dev/components/components-2/alert/alert.html.twig

components/components-2/alert/alert.html.twig
{#
/**
 * @file
 * Template for alert component.
 * Docs: https://italia.github.io/bootstrap-italia/docs/componenti/alert/
 * Latest revision: v2.8.7
 *
 * Parameters:
 * - heading (string) (default: '')
 *   - Optional heading
 * - heading_tag (string) (default: 'h4')
 * - message (string) (default: '')
 *   - Alert message
 * - type (string) (default: 'info')
 *   - options ["primary", info", "success", "warning", "danger"]
 * - dismissible (boolean) (default: true)
 *   - Enable dismissible feature
 * - animated_dismiss (boolean) (default: true)
 *   - Enable animation
 * - alert_classes (array) (default: [])
 * - alert_attributes (obj attribute) (default: '')
 *   - Object with extra attributes
 *
 * - alertContent (block) (default: message)
 *
 * Examples:
   {% include '@bi-bcl/alert/alert.html.twig' with {
      message: drupal_field_name,
      type: 'info'
   } %}
 *
 */
#}
{% apply spaceless %}
  {# Set defaults #}
  {% set _heading = heading|default('') %}
  {% set _heading_tag = heading_tag|default('h4') %}
  {% set _message = message|default('') %}
  {% set _type = type|default('info') %}
  {% set _dismissible = dismissible ?? true %}
  {% set _animated_dismiss = animated_dismiss ?? true %}
  {% set _alert_classes = alert_classes|default('') %}
  {% set _alert_attributes = alert_attributes|default('') %}

  {# Set options #}
  {% set _classes = [
    'alert',
    _type ? 'alert-' ~ _type,
    _dismissible ? 'alert-dismissible',
    _animated_dismiss ? 'fade',
    _animated_dismiss ? 'show',
  ] %}

  {% if _alert_classes is not empty %}
    {% set _classes = _classes|merge(alert_classes) %}
  {% endif %}

  {% if _alert_attributes is empty %}
    {% set alert_attributes = create_attribute() %}
  {% endif %}
  {% set alert_attributes = alert_attributes
    .addClass(_classes)
    .setAttribute('role', 'alert')
  %}

  {# Component #}
  <div {{ alert_attributes }}>
    {% block alertHeading %}
      {%- if _heading is not empty -%}
        <{{ _heading_tag }} class="alert-heading{{ _heading_tag != 'h4' ? ' h4' }}">{{ _heading }}</{{ _heading_tag }}>
      {%- endif -%}
    {% endblock %}

    {% block alertContent %}
      {%- if _message is not empty -%}
        {{- _message -}}
      {%- endif -%}
    {% endblock %}

    {%- if _dismissible -%}
      <button
        aria-label="{{ 'Close alert'|t }}"
        type="button"
        class="btn-close"
        data-bs-dismiss="alert"
      >
        {% include '@bi-bcl/icon/icon.html.twig' with {
          name: 'it-close',
        } %}
      </button>
    {%- endif -%}
  </div>
{% endapply %}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc