{# LIBRARIES #}
{{ attach_library('ui_patterns/menu_tb.menu_tb_lib') }}

{# VARIABLES #}
{% set mid = mid|default(random()) %}

{% set wrapper_attributes = wrapper_attributes|default(create_attribute())%}
{% set wrapper_classes = [
  wrapper_class ? wrapper_class : "",
  "nav",
  "nav-tabs",
  "nav-tabbed",
  "branded",
  "ulc", "ulin"
]%}

{# TEMPLATE #}
{% if links %}
  <nav aria-label="Tabbed menu {{ mid }}">
    <ul {{ wrapper_attributes.addClass(wrapper_classes) }} >
      {% for link in links %}
        {% if link['title'] != '<none>' %}
          {% set active = link['active'] ? ' active' : '' %}
          <li class="nav-item">
            {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
              "text": link['title'],
              "url": link['url'],
              "icon_left": link['icon'],
              "class": 'nav-link' ~ active,
            } only %}
          </li>
        {% endif %}
      {% endfor %}
    </ul>
  </nav>
{% endif %}
