convert home to alpine
This commit is contained in:
parent
4f8f01aa95
commit
77074c47bf
9 changed files with 159 additions and 42 deletions
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue