{# LIBRARIES #}
{{ attach_library('ui_patterns/menu_bg.menu_bg_lib') }}

{# VARIABLES #}
{% set icon = icon|default("chevron-down") %}
{% set mid = mid|default(random()) %}

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

{# TEMPLATE #}
{% if links %}
  <nav aria-label="Inline menu {{ mid }}">
    <ul {{ wrapper_attributes.addClass(wrapper_classes) }} >
      {% for link in links %}
        {% if link['title'] != '<none>' %}
          <li class="lic liin">
            {% set active = link['active'] ? ' active' : '' %}

            {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
              "text": link['title'],
              "url": link['url'],
              "icon_left": link['icon'],
              "attr": link_attr,
              "class": link['class'] ~ active,
            } only %}
          </li>
        {% endif %}
      {% endfor %}
    </ul>
  </nav>
{% endif %}
