-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #926 from sau-mili/main
feat: FAQ Page inproved
- Loading branch information
Showing
6 changed files
with
613 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
const toggles = document.querySelectorAll(".faq-toggle"); | ||
|
||
toggles.forEach((toggle) => { | ||
toggle.addEventListener("click", () => { | ||
toggle.parentElement.classList.toggle("active"); | ||
const accordions = document.querySelectorAll(".accordion"); | ||
|
||
accordions.forEach((accordion, index) => { | ||
const header = accordion.querySelector(".accordion__header"); | ||
const content = accordion.querySelector(".accordion__content"); | ||
const icon = accordion.querySelector("#accordion-icon"); | ||
|
||
header.addEventListener("click", () => { | ||
const isOpen = content.style.height === `${content.scrollHeight}px`; | ||
|
||
accordions.forEach((a, i) => { | ||
const c = a.querySelector(".accordion__content"); | ||
const ic = a.querySelector("#accordion-icon"); | ||
|
||
c.style.height = i === index && !isOpen ? `${c.scrollHeight}px` : "0px"; | ||
ic.classList.toggle("ri-add-line", i !== index || !isOpen); | ||
ic.classList.toggle("ri-subtract-fill", i === index && !isOpen); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.