<header class="n7-header shadow-md" id="siteHeader" aria-label="Header del sito">
    <!-- Top bar -->
    <div class="n7-top-bar flex items-center py-1 md:py-2 px-4 n7-background-gray-02 hidden lg:flex">
        <div class="n7-top-bar__container xl:container mx-auto flex items-center lg:flex-1">
            <div class="n7-top-bar__navigation grid lg:flex items-center gap-2 lg:gap-8">
                <!-- LINK CERTIFICAZIONE ISO  -->
                <a href="" class="n7-link gap-2 p-0 text-xs lg:text-sm n7-content-01">
                    <img src="/images/iso-27001.png" alt="ISO 27001" width="75" height="38">
                    Certificazione ISO/IEC 27001
                </a>
                <!-- Secondary nav/menu component -->
                <nav aria-label="Secondaria">
                    <ul class="n7-secondary-navigation lg:flex gap-4">

                        <li class="">
                            <a href="" class="n7-link p-2 text-xs lg:text-sm n7-content-01">voce 1</a>
                        </li>

                        <li class="">
                            <a href="" class="n7-link p-2 text-xs lg:text-sm n7-content-01">voce 2</a>
                        </li>

                    </ul>
                </nav>
            </div>

            <div class="n7-top-bar__utilities-area ml-auto">

                <!-- Search component -->
                <div class="hidden lg:block">
                    <button type="button" id="searchModalTrigger" class="n7-btn n7-btn--secondary n7-btn--icon rounded-full w-6 h-6 md:w-10 md:h-10">
                        <span class="sr-only">Cerca nel sito di Artea - apri la modale</span>
                        <svg class="inline-block align-middle fill-current w-4 h-4 md:w-5 md:h-5" aria-hidden="true" focusable="false" role="img">
                            <use xlink:href="../../icons.svg#mini--magnifying-glass" />
                        </svg>

                    </button>

                    <!-- Search Modal -->
                    <div id="searchModal" class="fixed items-center content-center inset-0 bg-black bg-opacity-50 overflow-y-auto h-full w-full" style="display:none;" aria-hidden="true" role="dialog" aria-modal="true" aria-labelledby="modalTitle">

                        <div class="relative h-full lg:h-full lg:w-full mx-auto p-6 lg:p-16 shadow-lg bg-white">
                            <div class="container px-16 grid gap-14">
                                <div class="flex justify-between items-center">
                                    <h2 id="modalTitle" class="text-3xl md:text-5xl lg:text-6xl">Cerca nel sito di Artea</h2>
                                    <button id="closeModal" class="n7-btn n7-btn--icon border-0 hover:n7-background-primary hover:text-white">
                                        <span class="sr-only">Chiudi</span>
                                        <svg class="inline-block align-middle fill-current w-8 h-8" aria-hidden="true" focusable="false" role="img">
                                            <use xlink:href="../../icons.svg#mini--x-mark" />
                                        </svg>

                                    </button>
                                </div>

                                <div class="modal-content">
                                    <form role="search" class="flex gap-2">
                                        <div class="n7-input-field grid gap-3 flex-1">
                                            <label for="inputSearch" class="block text-sm font-medium n7-content-03">Cerca servizi, informazioni, aiuti...</label>

                                            <div class="n7-input flex items-center relative">

                                                <svg class="inline-block align-middle fill-current w-6 h-6 absolute left-4 n7-content-placeholder" aria-hidden="true" focusable="false" role="img">
                                                    <use xlink:href="../../icons.svg#mini--magnifying-glass" />
                                                </svg>

                                                <input id="inputSearch" class="w-full border-2 n7-border-gray-01 text-sm n7-input-placeholder py-3 px-4 border n7-border-gray-01 rounded-lg pl-12 " type="search" placeholder="Cerca">

                                            </div>
                                        </div>

                                        <button type="button" class="n7-btn 
    n7-btn--primary
    n7-btn--primary self-end">
                                            Cerca nel sito

                                            <svg class="inline-block align-middle fill-current w-4 h-4 md:w-5 md:h-5 lg:w-6 lg:h-6 ml-2 transition-all duration-200 ease-out transform group-hover:translate-x-1" aria-hidden="true" focusable="false" role="img">
                                                <use xlink:href="../../icons.svg#mini--chevron-right" />
                                            </svg>

                                        </button>

                                    </form>

                                </div><!-- /END MODAL CONTENT -->
                            </div>
                        </div>

                    </div>
                </div><!--/ END SEARCH WRAPPER -->

            </div><!--/ END TOP BAR UTILITIES -->

        </div>
    </div><!-- /END TOPBAR -->
    <!-- Main heading -->
    <div class="n7-main-heading bg-white flex items-center px-4 py-2 lg:p-4 border-b n7-border-primary lg:border-b-0">
        <div class="xl:container mx-auto flex items-center flex-1">
            <div class="flex items-center n7-branding site-branding lg:max-w-[35.7%]">
                <a class="n7-site-logo site-logo flex w-10 h-10 md:flex-1 md:w-auto md:h-auto md:max-w-[124px] lg:max-w-[248px]" href="#">
                    <img class="w-full h-full object-cover md:object-contain object-left-top" src="/images/regione-toscana.png" alt="Alt logo image" width="248" height="81" />
                </a>

                <span class="w-4 h-10 md:w-10 md:h-20 bg-no-repeat bg-left-top bg-cover" style="background-image: url('/images/vertical-divider.svg')"></span>
                <a class="n7-site-logo site-logo flex w-46 h-10 md:flex-1 md:w-auto md:h-auto md:max-w-[124px] lg:max-w-[248px]" href="#">
                    <img class="w-full h-full object-contain object-left-top" src="/images/artea.png" alt="Alt logo image" width="248" height="81" />
                </a>

            </div>
            <div class="flex-1 lg:ml-auto lg:justify-end">
                <nav class="n7-primary-navigation flex lg:justify-end" aria-label="Principale" id="siteNavWrapper">
                    <button type="button" class="n7-btn 
    n7-btn--only-text rounded-0 lg:hidden ml-auto n7-btn--icon group" aria-expanded="false" aria-controls="mainNavPanel" id="mobileNavToggle">
                        <svg class="inline-block align-middle fill-current w-4 h-4 md:w-5 md:h-5 lg:w-6 lg:h-6 m-0 p-0 transition-all duration-200 ease-out transform group-hover:translate-none is-show-menu group-aria-expanded:hidden" aria-hidden="true" focusable="false" role="img">
                            <use xlink:href="../../icons.svg#mini--bars-3" />
                        </svg>

                        <svg class="inline-block align-middle fill-current w-4 h-4 md:w-5 md:h-5 lg:w-6 lg:h-6 m-0 p-0 transition-all duration-200 ease-out transform group-hover:translate-none is-close-menu hidden group-aria-expanded:inline-block" aria-hidden="true" focusable="false" role="img">
                            <use xlink:href="../../icons.svg#mini--x-mark" />
                        </svg>

                        <span class="sr-only is-show-menu group-aria-expanded:hidden">
                            Menu
                        </span>
                        <span class="sr-only is-close-menu hidden group-aria-expanded:block">
                            Chiudi menu
                        </span>
                    </button>
                    <!-- Mobile panel -->
                    <div class="n7-primary-navigation__panel flex-col bg-white transition-all invisible w-[88%] lg:w-auto fixed lg:static lg:visible top-[--header-height] bottom-0 left-[12%] lg:left-0 border-l n7-border-primary lg:border-l-0 overflow-y-auto" id="mainNavPanel">
                        <!-- Main nav -->
                        <div class="n7-primary-navigation__module is-main lg:border-b-0">
                            <ul class="n7-primary-navigation__list lg:flex lg:justify-end gap-4 xl:gap-8 has-dropdown-menu">
                                <li class="n7-dropdown-menu n7-primary-navigation__item">
                                    <button class="n7-dropdown-menu__trigger dropdown-trigger group w-full flex items-center p-3 gap-2 text-sm lg:text-base font-medium hover:underline focus:n7-content-primary aria-expanded:n7-background-gray-02 lg:aria-expanded:bg-white aria-expanded:n7-content-01" aria-expanded="false" aria-controls="submenumenu-01">
                                        Menu item 1<svg class="inline-block align-middle fill-current w-5 h-5 ml-auto transition-all n7-dropdown-menu__trigger-icon group-aria-expanded:-rotate-180" aria-hidden="true" focusable="false" role="img">
                                            <use xlink:href="../../icons.svg#mini--chevron-down" />
                                        </svg>
                                    </button>
                                    <ul class="n7-dropdown-menu__list hidden lg:absolute border border-t-0 n7-border-gray-01 lg:border-t lg:rounded lg:shadow-md lg:w-52 border-r-0 border-l-0 lg:border-r lg:border-l " id="submenumenu-01">

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                voce 1
                                            </a>
                                        </li>

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                voce 2
                                            </a>
                                        </li>

                                    </ul>
                                </li>
                                <li class="n7-dropdown-menu n7-primary-navigation__item">
                                    <button class="n7-dropdown-menu__trigger dropdown-trigger group w-full flex items-center p-3 gap-2 text-sm lg:text-base font-medium hover:underline focus:n7-content-primary aria-expanded:n7-background-gray-02 lg:aria-expanded:bg-white aria-expanded:n7-content-01" aria-expanded="false" aria-controls="submenumenu-02">
                                        Menu item 2<svg class="inline-block align-middle fill-current w-5 h-5 ml-auto transition-all n7-dropdown-menu__trigger-icon group-aria-expanded:-rotate-180" aria-hidden="true" focusable="false" role="img">
                                            <use xlink:href="../../icons.svg#mini--chevron-down" />
                                        </svg>
                                    </button>
                                    <ul class="n7-dropdown-menu__list hidden lg:absolute border border-t-0 n7-border-gray-01 lg:border-t lg:rounded lg:shadow-md lg:w-52 border-r-0 border-l-0 lg:border-r lg:border-l " id="submenumenu-02">

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                Item label 1
                                            </a>
                                        </li>

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                Item label 3
                                            </a>
                                        </li>

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                Item label 4
                                            </a>
                                        </li>

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                Item label 5
                                            </a>
                                        </li>

                                    </ul>
                                </li>
                                <li class="n7-dropdown-menu n7-primary-navigation__item">
                                    <button class="n7-dropdown-menu__trigger dropdown-trigger group w-full flex items-center p-3 gap-2 text-sm lg:text-base font-medium hover:underline focus:n7-content-primary aria-expanded:n7-background-gray-02 lg:aria-expanded:bg-white aria-expanded:n7-content-01" aria-expanded="false" aria-controls="submenumenu-03">
                                        Menu item 3<svg class="inline-block align-middle fill-current w-5 h-5 ml-auto transition-all n7-dropdown-menu__trigger-icon group-aria-expanded:-rotate-180" aria-hidden="true" focusable="false" role="img">
                                            <use xlink:href="../../icons.svg#mini--chevron-down" />
                                        </svg>
                                    </button>
                                    <ul class="n7-dropdown-menu__list hidden lg:absolute border border-t-0 n7-border-gray-01 lg:border-t lg:rounded lg:shadow-md lg:w-52 border-r-0 border-l-0 lg:border-r lg:border-l " id="submenumenu-03">

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                Item label 1
                                            </a>
                                        </li>

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                Item label 3
                                            </a>
                                        </li>

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                Item label 4
                                            </a>
                                        </li>

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                Item label 5
                                            </a>
                                        </li>

                                    </ul>
                                </li>
                                <li class="n7-dropdown-menu n7-primary-navigation__item">
                                    <button class="n7-dropdown-menu__trigger dropdown-trigger group w-full flex items-center p-3 gap-2 text-sm lg:text-base font-medium hover:underline focus:n7-content-primary aria-expanded:n7-background-gray-02 lg:aria-expanded:bg-white aria-expanded:n7-content-01" aria-expanded="false" aria-controls="submenumenu-04">
                                        Menu item 4<svg class="inline-block align-middle fill-current w-5 h-5 ml-auto transition-all n7-dropdown-menu__trigger-icon group-aria-expanded:-rotate-180" aria-hidden="true" focusable="false" role="img">
                                            <use xlink:href="../../icons.svg#mini--chevron-down" />
                                        </svg>
                                    </button>
                                    <ul class="n7-dropdown-menu__list hidden lg:absolute border border-t-0 n7-border-gray-01 lg:border-t lg:rounded lg:shadow-md lg:w-52 border-r-0 border-l-0 lg:border-r lg:border-l " id="submenumenu-04">

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                Item label 1
                                            </a>
                                        </li>

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                Item label 3
                                            </a>
                                        </li>

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                Item label 4
                                            </a>
                                        </li>

                                        <li class="n7-dropdown-menu__item group border-b n7-border-gray-01 last-of-type:border-b-0">
                                            <a class="flex p-3 gap-2 items-center transition bg-white text-sm xl:text-base hover:underline hover:n7-background-gray-02 focus:n7-background-gray-02 group-first:rounded-t group-last:rounded-b" href="">
                                                Item label 5
                                            </a>
                                        </li>

                                    </ul>
                                </li>
                                <!-- only link item -->
                                <li class="n7-primary-navigation__item">
                                    <a href="" class="w-full flex items-center p-3 gap-2 text-sm lg:text-base font-medium hover:underline focus:n7-content-primary">
                                        Voce 1
                                    </a>
                                </li>
                            </ul>
                        </div>

                        <!-- Mobile search in panel -->
                        <div class="n7-primary-navigation__module is-main lg:hidden">
                            <form role="search" class="flex items-end p-3">
                                <div class="n7-input-field grid gap-3 flex-1">
                                    <label for="inputSearchMobile" class="block text-sm font-medium n7-content-03">Cerca servizi, informazioni, aiuti...</label>

                                    <div class="n7-input flex items-center relative">

                                        <svg class="inline-block align-middle fill-current w-6 h-6 absolute left-4 n7-content-placeholder" aria-hidden="true" focusable="false" role="img">
                                            <use xlink:href="../../icons.svg#mini--magnifying-glass" />
                                        </svg>

                                        <input id="inputSearchMobile" class="w-full border-2 n7-border-gray-01 text-sm n7-input-placeholder py-3 px-4 border n7-border-gray-01 rounded-l-lg rounded-r-none pl-12 " type="search" placeholder="Cerca">

                                    </div>
                                </div>
                                <button type="button" class="n7-btn n7-btn--secondary n7-btn--icon w-12 h-12">
                                    <span class="sr-only">Cerca</span>
                                    <svg class="inline-block align-middle fill-current w-5 h-5" aria-hidden="true" focusable="false" role="img">
                                        <use xlink:href="../../icons.svg#mini--magnifying-glass" />
                                    </svg>

                                </button>
                            </form>
                        </div>

                    </div>
                    <div class="n7-primary-navigation__backdrop bg-black/25 top-[--header-height] lg:hidden"></div>
                </nav>
            </div>
        </div>
    </div>

</header>
<header class="n7-header{% if hasShadow %} shadow-md{% endif %}" id="siteHeader" aria-label="Header del sito">
    <!-- Top bar -->
    {% render '@top-bar', {hasSearchButton: 'true', mobileHidden: 'true'}, true %}
    <!-- Main heading -->
    {% render '@main-heading',{logoDivider: 'true'}, true %}
</header>
{
  "hasShadow": true
}
  • Content:
    /* HEADER SCRIPT - mobile management */
    document.addEventListener('DOMContentLoaded', function () {
        'use strict';
        if (document.querySelector('.n7-header')) {
            /* GLOBAL VARIABLES */
            var rootElement = document.documentElement;
            var siteHeader = document.querySelector('.n7-header');
            // var breadcrumb = document.querySelector('.n7-breadcrumb');
            var headerHeight;
            // var breadcrumbHeight;
    
            var mainMenuWrapper = document.getElementById('mainNavPanel');
            // var headerMainArea = document.querySelector('.region-header-main-area');
            // var headerSocialLinks = document.querySelector('.region-header-top-area-first .n7-social-media-links');
            var headerSecondaryNav = document.querySelector('.n7-top-bar__navigation');
            // var headerSearch = document.querySelector('.region-header-top-area-second');
    
            var SiteMenuWrapper = document.getElementById('siteNavWrapper');
    
            /* FUNCTIONS */
    
            function toggleIcon(icon) {
                if (icon.classList.contains('is-hidden')) {
                    icon.classList.remove('is-hidden');
                    icon.classList.add('is-visible');
                } else if (icon.classList.contains('is-visible')) {
                    icon.classList.remove('is-visible');
                    icon.classList.add('is-hidden');
                }
            }
    
            function calculateSiteHeader(header) {
                headerHeight = header.offsetHeight;
                rootElement.style.setProperty('--header-height', headerHeight + 'px');
            }
    
            function calculateBreadcrumbHeader(breadcrumb) {
                breadcrumbHeight = breadcrumb.offsetHeight;
                rootElement.style.setProperty('--breadcrumb-height', breadcrumbHeight + 'px');
            }
    
            function ariaExpandedToggle(target) {
                if (target.getAttribute('aria-expanded') === "false") {
                    target.setAttribute('aria-expanded', 'true');
                } else {
                    target.setAttribute('aria-expanded', 'false');
                }
            }
    
            function openOffCanvasMenu(button, targetMenu) {
                button.classList.toggle('is-selected');
                ariaExpandedToggle(button);
                targetMenu.classList.toggle('is-open');
                document.body.classList.toggle('overflow-hidden');
            }
    
            function closeMobileMenu() {
                if (document.body.classList.contains('overflow-hidden')) {
                    document.body.classList.remove('overflow-hidden');
                }
    
                mainMenuWrapper.classList.remove('is-open');
                document.getElementById('mobileNavToggle').setAttribute('aria-expanded', 'false');
                document.getElementById('mobileNavToggle').classList.remove('is-selected');
            }
    
            // function wrapAndAppend(wrapperClass, elementToWrap, parentElement) {
            //     var wrapperDiv = document.createElement('div');
            //     wrapperDiv.classList.add(wrapperClass);
            //     wrapperDiv.appendChild(elementToWrap);
            //     parentElement.appendChild(wrapperDiv);
            // }
    
            function wrapAndAppend(wrapperClass, elementToWrap, parentElement) {
                if (!document.querySelector('.' + wrapperClass + ':not(.is-main)')) {
                    var wrapperDiv = document.createElement('div');
                    wrapperDiv.classList.add(wrapperClass);
                    wrapperDiv.appendChild(elementToWrap);
                    parentElement.prepend(wrapperDiv);
                }
            }
    
    
            function unwrapAndRemove(wrapperDiv, elementToUnwrap, parentElement) {
                if (elementToUnwrap && elementToUnwrap.parentNode === parentElement) {
                    parentElement.removeChild(elementToUnwrap);
                }
    
                if (wrapperDiv && wrapperDiv.parentNode === parentElement) {
                    parentElement.removeChild(wrapperDiv);
                }
            }
    
            function handleResize() {
                var windowWidth = window.innerWidth;
                if (window.matchMedia("screen and (max-width: 1023px)").matches) {
                    wrapAndAppend('n7-primary-navigation__module', headerSecondaryNav, mainMenuWrapper);
    
                    // Wrappo headerSecondaryNav in un div con classe 'n7-primary-navigation__module'
                    // var mobileModuleWrap = document.createElement('div');
                    // mobileModuleWrap.classList.add('n7-primary-navigation__module');
    
                    // mainMenuWrapper.appendChild(mobileModuleWrap);
                    // mobileModuleWrap.appendChild(headerSecondaryNav);
    
    
                    // mainMenuWrapper.appendChild(headerSocialLinks);
                    // headerMainArea.insertBefore(headerSearch, headerMainArea.firstChild);
    
                    // mainMenuWrapper.setAttribute('aria-hidden', 'true');
    
                    // if (!document.querySelector('.n7-primary-navigation__module')) {
                    // wrapAndAppend('n7-primary-navigation__module', headerSecondaryNav, mainMenuWrapper);
                    // }
    
    
                    // calculateSiteHeader(siteHeader);
                    // calculateBreadcrumbHeader(breadcrumb);
    
    
                    calculateSiteHeader(siteHeader);
    
                } else if (window.matchMedia("screen and (min-width: 1024px)").matches) {
    
                    // mainMenuWrapper.removeChild(headerSocialLinks);
    
                    // if (!headerSecondaryNav) {
                    //     mainMenuWrapper.removeChild(headerSecondaryNav);
                    // }
    
                    // if (navModule && !navModule.contains(headerSecondaryNav)) {
                    //     mainMenuWrapper.removeChild(navModule);
                    // }
    
                    // headerMainArea.removeChild(headerSearch);
    
                    // document.querySelector('.region-header-top-area-first').appendChild(headerSocialLinks);
                    // document.querySelector('.sase-header__top-area-container').appendChild(headerSearch);
    
                    // mainMenuWrapper.removeAttribute('aria-hidden');
                    // calculateBreadcrumbHeader(breadcrumb);
                    // Se la viewport è maggiore o uguale a 768px, rimuovi tutti gli elementi .n7-primary-navigation__module vuoti
                    var emptyNavModules = document.querySelectorAll('.n7-primary-navigation__module:not(.is-main):empty');
    
                    emptyNavModules.forEach(function (emptyNavModule) {
                        unwrapAndRemove(emptyNavModule, headerSecondaryNav, mainMenuWrapper);
                    });
    
                    // Riporto headerSocialLinks nel suo posto originale
                    document.querySelector('.n7-top-bar__container').prepend(headerSecondaryNav);
    
                    calculateSiteHeader(siteHeader);
    
                }
            }
    
            window.addEventListener('resize', handleResize);
            handleResize(); // Initialize on page load
    
            document.getElementById('mobileNavToggle').addEventListener('click', function (e) {
                e.preventDefault();
                openOffCanvasMenu(this, mainMenuWrapper);
                console.log('clicked');
            });
    
            document.addEventListener('keyup', function (e) {
                // if (e.key === "Escape") {
                //     if (mainMenuWrapper.classList.contains('is-open')) {
                //         closeMobileMenu();
                //         if (window.getComputedStyle(document.getElementById('mobileNavToggle')).display !== 'none') {
                //             document.getElementById('mobileNavToggle').focus();
                //         }
    
                //         if (document.getElementById('mainMenuToggle')) {
                //             document.getElementById('mainMenuToggle').focus();
                //         }
                //     }
                // }
    
                if (e.key === "Escape") {
                    if (mainMenuWrapper.classList.contains('is-open')) {
                        // Verifica se il focus è all'interno del menu principale
                        const isFocusInsideMainMenu = SiteMenuWrapper.contains(document.activeElement) &&
                            !document.activeElement.closest('.n7-dropdown-menu__item');
    
                        if (isFocusInsideMainMenu) {
                            closeMobileMenu();
    
                            // Se disponibile, ripristina il focus sull'elemento principale di apertura menu
                            if (document.getElementById('mobileNavToggle')) {
                                document.getElementById('mobileNavToggle').focus();
                            }
                        }
                    }
                }
    
                if ((e.key === 'Tab' || e.keyCode === 9) && !mainMenuWrapper.contains(e.target)) {
                    closeMobileMenu();
                }
            });
    
            document.body.addEventListener('click', function (e) {
                if ((!SiteMenuWrapper.contains(e.target) || document.querySelector('.n7-primary-navigation__backdrop').contains(e.target)) && mainMenuWrapper.classList.contains('is-open')) {
                    closeMobileMenu();
                }
            });
    
        }
    });
    
    /* SEARCH DIALOG */
    const openModal = () => {
        const modal = document.getElementById('searchModal');
        const modalContent = modal.querySelector('.modal-content');
    
        modal.style.display = 'flex';
        modal.classList.add("z-10");
        modal.setAttribute('aria-hidden', 'false');
    
        // Get all the focusable elements inside the modal content
        const focusableElements = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
        const firstFocusable = modalContent.querySelectorAll(focusableElements)[0];
        const fallbackFocusable = modalContent.querySelector('.is-focusable-element'); // Adjust the selector if necessary
    
        // If there's a focusable element, focus on it; otherwise, focus on the fallback element
        if (firstFocusable) {
            firstFocusable.focus();
        } else if (fallbackFocusable) {
            fallbackFocusable.setAttribute('tabindex', '-1');
            fallbackFocusable.focus();
        }
    
        if (!document.body.classList.contains('overflow-hidden')) {
            document.body.classList.add('overflow-hidden');
        }
    };
    
    const closeModal = () => {
        const modal = document.getElementById('searchModal');
        const modalContent = modal.querySelector('.modal-content');
        const previouslyFocusedElement = document.getElementById('searchModalTrigger');
    
        // Remove tabindex from the fallback focusable element
        const fallbackFocusable = modalContent.querySelector('.is-focusable-element');
        if (fallbackFocusable) {
            fallbackFocusable.removeAttribute('tabindex');
        }
        
        if (document.body.classList.contains('overflow-hidden')) {
            document.body.classList.remove('overflow-hidden');
        }
    
        modal.style.display = 'none';
        modal.setAttribute('aria-hidden', 'true');
        modal.classList.remove("z-10");
        previouslyFocusedElement.focus();
    };
    
    if (document.getElementById('searchModal')) {
        document.getElementById('searchModalTrigger').addEventListener('click', openModal);
    
        document.getElementById('closeModal').addEventListener('click', closeModal);
    
        document.getElementById('searchModal').addEventListener('keydown', function (event) {
            const modalContent = document.querySelector('.modal-content');
            const focusableElements = modalContent.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
            const firstFocusableElement = focusableElements[0];
            const lastFocusableElement = focusableElements[focusableElements.length - 1];
    
            if (event.key === 'Tab') {
                if (event.shiftKey && document.activeElement === firstFocusableElement) {
                    lastFocusableElement.focus();
                    event.preventDefault();
                } else if (!event.shiftKey && document.activeElement === lastFocusableElement) {
                    firstFocusableElement.focus();
                    event.preventDefault();
                }
            }
    
            if (event.key === 'Escape') {
                closeModal();
            }
        });
    
        // window.addEventListener('click', function (event) {
        //     const modal = document.getElementById('searchModal');
        //     if (event.target === modal) {
        //         closeModal();
        //     }
        // });
    }
  • URL: /components/raw/header/header.js
  • Filesystem Path: components/04-organisms/header/header.js
  • Size: 12.2 KB

Modular header component. Components:

  • top-bar component: manage secondary menu, search, other utilities
  • main-heading: cointains one or more logos, main navigation
  • bottom-bar (work in progress)

Use hasShadow:true in configuration to add header box shadow