Szybki commit bo zmieniam komputer

This commit is contained in:
Dark Steveneq
2025-09-21 20:30:37 +02:00
parent 9c2b30b0fb
commit cfbea5f2f4
4 changed files with 101 additions and 80 deletions

View File

@@ -1,25 +1,29 @@
document.addEventListener("DOMContentLoaded", () => {
const akordeony = document.getElementsByClassName("akordeon");
for (const akordeon of akordeony) {
if (akordeon.children.length < 2) {
console.warn("Na stronie jest niepoprawnie skonfigurowany akordeon!")
continue;
}
const pierworodny = akordeon.children[0];
const nowy = document.createElement("div")
nowy.className = "akordeon-header";
nowy.onclick = () => {
const otwarte = akordeon.classList.contains("open");
akordeon.classList.remove(otwarte ? "open": "closed");
akordeon.classList.add(otwarte ? "closed" : "open");
for (const dziecko of akordeon.children) {
if (dziecko != nowy) {
dziecko.style.display = otwarte ? "" : "none";
}
}
}
akordeon.replaceChild(nowy, pierworodny)
nowy.append(pierworodny)
class Akordeon extends HTMLElement {
constructor() {
super();
this._internals = this.attachInternals();
}
})
get collapsed() {
return this._internals.states.has("hidden");
}
set collapsed(flag) {
if (flag) {
// Existence of identifier corresponds to "true"
this._internals.states.add("hidden");
} else {
// Absence of identifier corresponds to "false"
this._internals.states.delete("hidden");
}
}
connecterCallback() {
}
attributeChangedCallback(atrybut, poprzednio, obecnie) {
}
}
customElements.define("akordeon", Akordeon);