Commit 869d2f07 authored by James Candan's avatar James Candan Committed by Sohail Lajevardi
Browse files

Issue #3260136 by jcandan: Make nav default to dropdown links optional

parent 8679d77d
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
 * - alignment: left | right | center | vertical.
 * - style: tabs | pills
 * - fill: fill | justify
 * - is_dropdown: true | false
 * - utility_classes: An array of utility classes.
 */
#}
@@ -24,6 +25,7 @@

{% set style = style ? 'nav-' ~ style : '' %}
{% set fill = fill ? 'nav-' ~ fill : '' %}
{% set is_dropdown = is_dropdown is null ? true %}

{% set nav_classes = [ 'nav', style, alignment, fill]|merge(utility_classes ? utility_classes : []) %}

@@ -34,7 +36,7 @@
        {% set nav_item_classes = [
          'nav-item',
          item.in_active_trail ? 'active',
          item.is_expanded and item.below ? 'dropdown'
          is_dropdown ? 'dropdown'
        ] %}
        {% set nav_link_classes = ['nav-link'] %}
        {% if item.url.options.attributes.class is iterable %}
@@ -43,19 +45,22 @@
          {% set nav_link_classes = nav_link_classes|merge([item.url.options.attributes.class]) %}
        {% endif %}
        <li{{ item.attributes.addClass(nav_item_classes) }}>
          {% if item.is_expanded and item.below %}
          {% if item.is_expanded and item.below and is_dropdown %}
            {{ link(item.title, item.url, { 'class': nav_link_classes|merge(['dropdown-toggle']), 'data-toggle': 'dropdown' }) }}
            {% if item.below %}
            {% include '@radix/dropdown/dropdown-menu.twig' with {
              items: item.below
            } %}
            {% endif %}
          {% else %}
            {{ link(item.title, item.url, { 'class': nav_link_classes }) }}
            {% if item.is_expanded and item.below and not is_dropdown %}
              {% include '@evo_radix/nav/nav.twig' with {
                items: item.below,
                is_dropdown: false,
              } %}
            {% endif %}
          {% endif %}
        </li>
      {% endfor %}
    {% endblock %}
  </ul>
{% endif %}