bootstrap_italia-8.x-0.x-dev/templates/region/header-nav/menu--header-nav.html.twig
templates/region/header-nav/menu--header-nav.html.twig
{#
/**
* @file
* Default theme implementation to display a menu.
*
* Available variables:
* - menu_name: The machine name of the menu.
* - items: A nested list of menu items. Each menu item contains:
* - attributes: HTML attributes for the menu item.
* - below: The menu item child items.
* - title: The menu link title.
* - url: The menu link url, instance of \Drupal\Core\Url
* - localized_options: Menu link localized options.
* - is_expanded: TRUE if the link has visible children within the current
* menu tree.
* - is_collapsed: TRUE if the link has children within the current menu tree
* that are not currently visible.
* - in_active_trail: TRUE if the link is in the active trail.
*
* @ingroup themeable
*/
#}
{# Set default settings. #}
{% set navigation_header_megamenu_columns_lg = navigation_header_megamenu_columns_lg ?: 'col-lg-4' %}
{% set navigation_header_sticky_menu_name = navigation_header_sticky_menu_name ?: 'main' %}
{% set _navigation_header_data_attribute = pa_website_validator_type|default('')%}
{% set _navbar_attributes = create_attribute() %}
{# Detect primary menu. #}
{% if navigation_header_sticky_menu_name == menu_name %}
{% set _navbar_attributes = _navbar_attributes
.setAttribute('aria-label', 'Main navigation menu'|t)
.addClass(['ps-lg-0', 'flex-grow-1'])
%}
{% set attributes = attributes.addClass('ps-lg-0') %}
{# or secondary menu #}
{% else %}
{% set attributes = attributes.addClass(['navbar-secondary', 'pe-xl-0']) %}
{% set _navbar_attributes = _navbar_attributes
.setAttribute('aria-label', 'Secondary menu'|t)
.addClass('pe-xl-0')
%}
{% endif %}
{% if navigation_header_sticky_menu_name == menu_name and _navigation_header_data_attribute is not empty %}
{# Compliance C.SI.1.6 Municipality or C.SC.1.4 School #}
{% set site_attributes = [
_navigation_header_data_attribute == 'municipality' ? 'main-navigation',
_navigation_header_data_attribute == 'school' ? 'menu',
] %}
{% set attributes = attributes.setAttribute('data-element', site_attributes) %}
{% endif %}
{# Component. #}
<nav{{ _navbar_attributes }}>
{% include '@bi-bcl/megamenu/navbar-nav.html.twig' with {
menu_name: menu_name,
items: items,
attributes: attributes,
active_assistive_text: 'Current Page'|t,
show_link_description: navigation_header_show_link_description,
active_items_large: navigation_header_active_items_large,
active_items_bold: navigation_header_active_items_bold,
megamenu_responsive_columns: (navigation_header_megamenu_columns_lg ~ ' ' ~ navigation_header_megamenu_columns_xl)|trim,
verbose_classes: navigation_header_verbose_classes,
} %}
</nav>
