Changeset 83b8b8f in Klonkt for src/views/partials


Ignore:
Timestamp:
06/20/2026 02:04:32 PM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
999aad2
Parents:
2149f5a
Message:

feat(i18n): styled language dropdown in the header (instead of native select)

Custom dropdown (details/summary, like the user menu): toggle = globe + code +
chevron; menu = full names with code, accent on the active language, clean
shadow/border. Closes on outside click (handler extended). style.css?v=28.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/partials/topnav.ejs

    r2149f5a r83b8b8f  
    8282      </button>
    8383
    84       <% if (typeof langs !== 'undefined' && langs && langs.length > 1) { %>
    85         <select class="nav-lang" aria-label="<%= t('nav.language') %>" title="<%= t('nav.language') %>"
    86                 onchange="location.href='/lang/'+this.value+'?r='+encodeURIComponent(location.pathname+location.search)">
    87           <% langs.forEach(function(l){ %><option value="<%= l.code %>"<%= l.active ? ' selected' : '' %>><%= l.code.toUpperCase() %></option><% }); %>
    88         </select>
     84      <% if (typeof langs !== 'undefined' && langs && langs.length > 1) {
     85           var _curLang = (langs.find(function(l){ return l.active; }) || { code: 'nl' }).code;
     86           var _langR = (typeof currentPath !== 'undefined' && currentPath) ? currentPath : '/';
     87      %>
     88        <details class="lang-menu">
     89          <summary class="nav-btn lang-toggle" aria-label="<%= t('nav.language') %>" title="<%= t('nav.language') %>">
     90            <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>
     91            <span class="lang-code"><%= _curLang.toUpperCase() %></span>
     92            <svg class="lang-caret" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>
     93          </summary>
     94          <div class="lang-dropdown" role="menu">
     95            <% langs.forEach(function(l){ %>
     96              <a class="lang-item<%= l.active ? ' is-active' : '' %>" role="menuitem" href="/lang/<%= l.code %>?r=<%= encodeURIComponent(_langR) %>"><span class="lang-item-code"><%= l.code.toUpperCase() %></span><%= l.name %></a>
     97            <% }); %>
     98          </div>
     99        </details>
    89100      <% } %>
    90101
     
    210221    if (e.target.closest('#search-toggle')) { openSearch(); return; }
    211222    if (e.target.closest('#search-close')) { closeSearch(); return; }
    212     // Gebruikersmenu sluiten bij klik erbuiten.
    213     var open = document.querySelector('.user-menu[open]');
    214     if (open && !open.contains(e.target)) open.removeAttribute('open');
     223    // Open dropdowns (gebruikersmenu + taalkeuze) sluiten bij klik erbuiten.
     224    document.querySelectorAll('.user-menu[open], .lang-menu[open]').forEach(function(d) {
     225      if (!d.contains(e.target)) d.removeAttribute('open');
     226    });
    215227  });
    216228
Note: See TracChangeset for help on using the changeset viewer.