convert home to alpine

This commit is contained in:
isUnknown 2024-01-25 18:34:32 +01:00
parent 4f8f01aa95
commit 77074c47bf
9 changed files with 159 additions and 42 deletions

View file

@ -1,45 +1,31 @@
function toggleTab(event, tabName) {
hideAllTabs(event)
const button =
event.target.tagName === "BUTTON"
? event.target
: event.target.closest("button")
// const buttonTop = button.offsetTop
const icon = button.querySelector(".more-less-icon")
const article = document.querySelector("#" + tabName)
icon.textContent = icon.textContent === "+" ? "-" : "+"
button.classList.toggle("open")
article.classList.toggle("hidden")
function openTab(data, tab) {
data.activeTab === tab ? (data.activeTab = "") : (data.activeTab = tab);
}
function hideAllTabs(event) {
const tabContainer = event.target.closest("toggle")
const buttons = document.querySelectorAll(".toggle-btn")
const articles = document.querySelectorAll(".tab")
buttons.forEach((btn) => {
btn.classList.remove("open")
btn.querySelector(".more-less-icon").textContent = "+"
})
articles.forEach((article) => {
article.classList.add("hidden")
})
function scrollToElem(selector) {
setTimeout(() => {
const yOffset = -185;
const elem = document.querySelector(selector);
const top = elem.getBoundingClientRect().top;
window.scrollTo({
top: top + window.scrollY + yOffset,
behavior: "smooth",
});
}, 100);
}
document.addEventListener("DOMContentLoaded", () => {
function toggleLogoState() {
const scrollY = window.scrollY || window.pageYOffset
const scrollY = window.scrollY || window.pageYOffset;
if (scrollY > 10) {
document.querySelector("#header").classList.add("minimized")
document.querySelector("#header").classList.add("minimized");
} else {
document.querySelector("#header").classList.remove("minimized")
document.querySelector("#header").classList.remove("minimized");
}
}
window.addEventListener("scroll", () => {
toggleLogoState()
})
})
toggleLogoState();
});
});