feat: WIP: DropDown via JS implementiert.

Sieht noch scheiße aus, soll zum Test, ob das grundsätzlich geht aber reichen.
This commit is contained in:
muli 2024-01-21 21:42:06 +01:00
parent 15568aeb5d
commit b19740d7e4
4 changed files with 32 additions and 12 deletions

View File

@ -129,12 +129,12 @@ body {
text-decoration: underline; text-decoration: underline;
} }
.primary_nav__sub_navlist { .primary_nav__sub_navlist.-closed {
display: none; display: none;
z-index: 20; z-index: 20;
} }
.primary_nav__navlist > li:hover > .primary_nav__sub_navlist { .primary_nav__sub_navlist.-open {
display: block; display: block;
margin: 2.6rem 0 0 -0.5rem; margin: 2.6rem 0 0 -0.5rem;
padding: 0; padding: 0;

View File

@ -6,3 +6,17 @@ document.getElementsByClassName('primary_nav__toggle')[0].addEventListener('clic
nav_list.style.display = 'block'; nav_list.style.display = 'block';
} }
}); });
let primary_menu_items = document.getElementsByClassName('primary_nav__navitem');
for (let i = 0; i < primary_menu_items.length; i++) {
primary_menu_items[i].addEventListener('click', function(event) {
let dropdown = event.currentTarget.firstElementChild;
if (dropdown.classList.contains('-closed')) {
dropdown.classList.remove('-closed');
dropdown.classList.add('-open');
} else {
dropdown.classList.remove('-open');
dropdown.classList.add('-closed');
}
});
}

View File

@ -1,12 +1,14 @@
{ {
"Was wir tun": { "Was wir tun": {
"href": "/about", "href": "/about",
"slug": "about",
"visible": true, "visible": true,
"list_childs": false, "list_childs": false,
"items": {} "items": {}
}, },
"Was geht ab?": { "Was geht ab?": {
"href": "/aktuelles", "href": "/aktuelles",
"slug": "aktuelles",
"visible": true, "visible": true,
"list_childs": false, "list_childs": false,
"items": { "items": {
@ -16,8 +18,9 @@
}, },
"Mitglied werden": { "Mitglied werden": {
"href": "/mitglieder", "href": "/mitglieder",
"slug": "mitglieder",
"visible": true, "visible": true,
"list_childs": false, "list_childs": true,
"items": { "items": {
"Satzung": "/mitglieder/satzung", "Satzung": "/mitglieder/satzung",
"Mitglied werden": "/mitglieder/beitreten" "Mitglied werden": "/mitglieder/beitreten"

View File

@ -12,7 +12,11 @@
<ul class="primary_nav__navlist"> <ul class="primary_nav__navlist">
{% for title, mapping in bag("navigation").items() %} {% for title, mapping in bag("navigation").items() %}
{% if mapping.visible|default(true) %} {% if mapping.visible|default(true) %}
<li class="primary_nav__navitem"> <li id="{{ mapping.slug }}" class="primary_nav__navitem">
{{ title }}
{% if mapping.list_childs %}
<ul class="primary_nav__sub_navlist -closed">
<li>
<a class="primary_nav__navlink {% if this._path == mapping.href or <a class="primary_nav__navlink {% if this._path == mapping.href or
this._path in mapping['items'].values() or this._path in mapping['items'].values() or
title == 'Aktuelles' and title == 'Aktuelles' and
@ -20,8 +24,7 @@
%}-active{% endif %}" href="{{ mapping.href|url }}"> %}-active{% endif %}" href="{{ mapping.href|url }}">
{{ title }} {{ title }}
</a> </a>
{% if mapping.list_childs %} </li>
<ul class="primary_nav__sub_navlist">
{% set sub_menu = mapping['items'].items() %} {% set sub_menu = mapping['items'].items() %}
{% for sub_title, href in sub_menu %} {% for sub_title, href in sub_menu %}
<li class="primary_nav__sub_navitem"> <li class="primary_nav__sub_navitem">