SU-SWS/stanford_profile

View on GitHub
themes/stanford_basic/templates/menus/menu--main.html.twig

Summary

Maintainability
Test Coverage
{#
/**
 * @file
 * Main Navigation Component
 *
 * A navigation menu for the website.
 *
 * Available variables:
 * - attributes: For additional HTML attributes not already provided.
 * - modifier_class: Additional css classes to change look and behaviour of the component.
 * - toggle_modifier_class: Additional css classes to change look and behaviour of the toggle.
 * - aria_label: Aria label for the <nav> element. Default is "main menu". If there are multiple instances of the component on the same page, use a different aria_label for each instance.
 *
 */
#}
{% set toggle_text = "Menu"|t %}
{% set attributes = attributes.addClass(['su-multi-menu', 'su-multi-menu--buttons', 'su-multi-menu--right', 'no-js']) %}
{% set attributes = attributes.setAttribute('aria-label', 'main menu') %}
{# Macros #}
{%- import "@basic/menus/macros/nav-menu.twig" as menus -%}
<nav{{ attributes }}>
  {% block multimenubutton %}
  <button class="su-multi-menu__nav-toggle su-multi-menu__nav-toggle--right {{ toggle_modifier_class }}" aria-expanded="false">{{ toggle_text|default('Menu') }}</button>
  {% endblock %}
  {% apply spaceless %}
  {% if items is iterable %}
    {{ menus.nav_menu(items, 1, 'su-multi-menu') }}
  {% else %}
    {# If custom markup is provided, emit it as is #}
    {{ items }}
  {% endif %}
  {% endapply %}
</nav>