{{ attach_library('core/drupal.dropbutton') }}

{% set classes = [
  'c-dropbutton',
  'js-dropbutton',
  'has-multiple',
  modifier_classes ? modifier_classes : '',
]|join(' ')|trim %}

<div {{ add_attributes({class: classes}) }}>
  <ul class="c-dropbutton__list js-dropbutton-list">
    {%- for item in links -%}
    <li {{ add_attributes({class: "c-dropbutton__item"}, 'item_attributes') }}>
      {%- if item.link -%}
        {{ item.link }}
      {% elseif item.href and item.text %}
        <a {{ add_attributes({class: 'c-button c-dropbutton__button'}, 'item_link_attributes') }}{% if item.href %} href={{ item.href }}{% endif %}>
          {{ item.text }}
        </a>
      {%- elseif item.text_attributes -%}
        <span{{ item.text_attributes }}>{{ item.text }}</span>
      {%- else -%}
        {{ item.text }}
      {%- endif -%}
    </li>
    {%- endfor -%}
  </ul>
</div>
