Files
plugi/themes/theme-one/src/main.ts
T
deepDiverPaul ed8ae3200b refresh theme-one starter blocks and layout
Redesign the master layout and content blocks with responsive styling, accessible navigation, and configurable CTA and quote sections. Add about-me, embedded-code, and FAQ blocks, and update the generated theme assets. Replace Alpine-based locale handling with vanilla JavaScript for locale flags and gallery lightboxes, and remove Alpine and DaisyUI dependencies.
2026-11-25 17:50:12 +01:00

35 lines
1.2 KiB
TypeScript

import {localeMapper} from "./helpers/localemapper.ts";
const getFlagEmoji = (locale: string) => {
const countryCode = localeMapper(locale)
return String.fromCodePoint(...[...countryCode.toUpperCase()].map(x => 0x1f1a5 + x.charCodeAt(0)))
}
document.querySelectorAll<HTMLElement>("[data-locale-flag]").forEach((flag) => {
const locale = flag.dataset.locale
if (locale) {
flag.textContent = getFlagEmoji(locale)
}
})
document.querySelectorAll<HTMLElement>("[data-gallery]").forEach((gallery) => {
if (gallery.dataset.galleryLightbox !== "true") {
return
}
const dialog = gallery.querySelector<HTMLDialogElement>("[data-gallery-dialog]")
const lightboxImage = dialog?.querySelector<HTMLImageElement>("[data-gallery-lightbox-image]")
if (!dialog || !lightboxImage || typeof dialog.showModal !== "function") {
return
}
gallery.querySelectorAll<HTMLAnchorElement>("[data-gallery-trigger]").forEach((trigger) => {
trigger.addEventListener("click", (event) => {
event.preventDefault()
lightboxImage.src = trigger.href
lightboxImage.alt = trigger.querySelector("img")?.alt ?? ""
dialog.showModal()
})
})
})