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

{# VARIABLES #}
{% set mid = mid|default(random()) %}
{% set outline = outline|default(false) %}
{% set size = size|default('md') %}
{% set status = status|default('default') %}
{% set expanded = expanded|default(false) %}
{% set cols = cols|default(2) %}
{% set col_width = (12 / cols) %}

{# TEMPLATE #}
{% if links %}
  {% set nav_items = [] %}
  {% for link in links %}
    {% set nav_item %}

      {% include '@atoms/form/button/button.twig' with {
        'text': link['title'],
        "url": link['url'],
        "icon": link['icon'],
        "icon_position": link['icon_position'] ?? 'left',
        'outline': outline,
        'expanded': expanded,
        'size': size,
        'status': status,
        'class': 'mb-0',
      } %}

    {% endset %}
    {% set nav_items = nav_items|merge([nav_item]) %}
  {% endfor %}

  {% include "@organisms/tm-scaffold/rows-cols/rows-cols.twig" with {
    'wrapper_class': wrapper_class,
    'auto_height': true,
    'batch': cols,
    'items': nav_items,
    'col_class': 'col-sm-' ~ col_width ~ ' mb-3',
    'row_class': 'mb-0',
  } %}

{% endif %}
