{# LIBRARIES #}
{{ attach_library('ui_patterns/sa_list.sa_list_lib') }}

{# VARIABLES #}
{% set title = title|default('<i class="far fa-exclamation-circle"></i> Important updates') %}
{% set link_icon_right = link_icon_right|default(global_icon_right|default('fas fa-chevron-right')) %}
{% set attributes = attributes|default(create_attribute()) %}
{% set count = links|length %}
{% set expandable = expandable|default(false) %}
{% set classes = [
  'sa-list',
  expandable ? 'expandable' : '',
] %}

{# TEMPLATE #}
{% if links %}
  <div {{ attributes.addClass(classes) }}>
    <h2>{{ title }}</h2>
    <div class="of-content">
      <div class="announcement-list">
      {% for link in links %}
        <p>
          {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
            "text": link['text'],
            "url": link['url'],
            "icon_right": link_icon_right,
            "display": "noflex",
          } only %}
        </p>
      {% endfor %}
      </div>
      <div class="sa-footer">
        {{ footer }}
      </div>
    </div>
    {% if expandable %}
      <a href="#" class="expand">View all <span class="count">{{ count }}</span></a>
      <a href="#" class="close"><i class="far fa-times-circle"></i></a>
    {% else %}
      <button class="btn btn-sm btn-default rounded-3 ffl buy-tickets-btn d-md-none">Buy tickets</button>
    {% endif %}
  </div>
{% endif %}
