style: format static/anime.ts

This commit is contained in:
2026-06-21 02:04:28 +02:00
committed by Milas Holsting
parent 327af5f75a
commit 3228b5cfa6

View File

@@ -2,15 +2,21 @@ import { closestFocusable, onReady } from "./utils";
const initSynopsisToggle = (): void => { const initSynopsisToggle = (): void => {
document.addEventListener("click", (event) => { document.addEventListener("click", (event) => {
const target = event.target; const { target } = event;
if (!(target instanceof Element)) return; if (!(target instanceof Element)) {
return;
}
const button = target.closest<HTMLButtonElement>("[data-synopsis-toggle]"); const button = target.closest<HTMLButtonElement>("[data-synopsis-toggle]");
if (!button) return; if (!button) {
return;
}
const section = button.closest("section"); const section = button.closest("section");
const container = section?.querySelector<HTMLElement>("[data-synopsis-container]"); const container = section?.querySelector<HTMLElement>("[data-synopsis-container]");
if (!container) return; if (!container) {
return;
}
const isClamped = container.classList.contains("line-clamp-6"); const isClamped = container.classList.contains("line-clamp-6");
container.classList.toggle("line-clamp-6", !isClamped); container.classList.toggle("line-clamp-6", !isClamped);
@@ -25,7 +31,9 @@ const initThemesDialog = (): void => {
const closeButton = document.querySelector<HTMLButtonElement>("[data-themes-close]"); const closeButton = document.querySelector<HTMLButtonElement>("[data-themes-close]");
const content = document.querySelector<HTMLElement>("[data-themes-content]"); const content = document.querySelector<HTMLElement>("[data-themes-content]");
const loader = document.querySelector<HTMLElement>("[data-themes-loader]"); const loader = document.querySelector<HTMLElement>("[data-themes-loader]");
if (!dialog || !openButton || !content || !loader) return; if (!dialog || !openButton || !content || !loader) {
return;
}
let themesRequested = false; let themesRequested = false;
let lastFocused: HTMLElement | null = null; let lastFocused: HTMLElement | null = null;
@@ -37,7 +45,9 @@ const initThemesDialog = (): void => {
dialog.setAttribute("aria-hidden", "false"); dialog.setAttribute("aria-hidden", "false");
closestFocusable(dialog)?.focus(); closestFocusable(dialog)?.focus();
if (themesRequested) return; if (themesRequested) {
return;
}
themesRequested = true; themesRequested = true;
content.textContent = "Loading theme songs..."; content.textContent = "Loading theme songs...";
const htmxApi = ( const htmxApi = (
@@ -61,8 +71,12 @@ const initThemesDialog = (): void => {
} }
}); });
document.addEventListener("keydown", (event) => { document.addEventListener("keydown", (event) => {
if (event.key !== "Escape") return; if (event.key !== "Escape") {
if (dialog.classList.contains("hidden")) return; return;
}
if (dialog.classList.contains("hidden")) {
return;
}
event.preventDefault(); event.preventDefault();
close(); close();
}); });