Files
fewo-stommer/resources/themes/seebad/theme.js
T
LarsandClaude Opus 5.5 d2f53ceb84 Theme Seebad 0.4.0: menu panels; fix missing chevron icons; render test for all themes
- Menu panels: arrow next to each main menu item opens a panel with the page description (SEO text),
  jump links to the headed sections and a cartouche with booking and phone; Escape/outside click closes,
  focus returns; without JavaScript the menu stays plain links
- Header: booking button hidden between 1280 and 1535 px (too narrow with the arrows), desktop phone removed
- Fix: offers carousel and menu used outline chevron icons that do not exist (500 as soon as offers are shown);
  now mini chevrons
- New test: every installed theme renders all pages with reviews and offers in every display mode
- Wish: menu photo per page (ZUSAMMENARBEIT §5)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 12:33:11 +02:00

53 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Theme „Seebad“: übernimmt Lightbox, Verfügbarkeitssuche und rollierende Angebote vom Eltern-Theme.
* Eigene Verbesserungen darunter – alles muss auch ohne JavaScript funktionieren.
*/
import '../ostsee-licht/theme.js';
// Logo, favicon (resources/themes/seebad/img) – addressed in Blade via Vite::asset().
import.meta.glob(['./img/**'], { eager: true, query: '?url' });
/**
* Menu panels (partials/header): the arrow next to a menu item opens a panel with jump links into the page.
* Without JavaScript the arrows stay hidden and the menu items are plain links.
*/
function initMenuPanels() {
const header = document.querySelector('[data-menu]');
const toggles = [...document.querySelectorAll('[data-menu-toggle]')];
if (!header || toggles.length === 0) {
return;
}
const panelOf = (toggle) => document.getElementById(toggle.getAttribute('aria-controls'));
const close = (toggle) => {
toggle.setAttribute('aria-expanded', 'false');
panelOf(toggle).hidden = true;
};
toggles.forEach((toggle) => {
toggle.hidden = false;
toggle.addEventListener('click', () => {
const open = toggle.getAttribute('aria-expanded') === 'true';
toggles.filter((other) => other !== toggle).forEach(close);
toggle.setAttribute('aria-expanded', String(!open));
panelOf(toggle).hidden = open;
});
});
document.addEventListener('keydown', (event) => {
const open = toggles.find((toggle) => toggle.getAttribute('aria-expanded') === 'true');
if (event.key === 'Escape' && open) {
close(open);
open.focus();
}
});
document.addEventListener('click', (event) => {
if (!header.contains(event.target)) {
toggles.forEach(close);
}
});
window.matchMedia('(min-width: 80rem)').addEventListener('change', () => toggles.forEach(close));
}
initMenuPanels();