-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@import "../accordion/accordion.css"; | ||
|
||
/* inside accordion group we can have text below first div */ | ||
|
||
.shade-box { | ||
background-color: var(--spectrum-gray-100); | ||
padding: 14px 21px 21px; | ||
border-radius: 7px; | ||
margin-bottom: 28px; | ||
} | ||
|
||
.accordion-group>.accordion details div { | ||
font-size: var(--exlm-font-size-content); | ||
line-height: var(--exlm-line-height-h4); | ||
margin-left: 14px; | ||
margin-top: 14px; | ||
} | ||
|
||
/* override /docs font size */ | ||
.accordion-group>.accordion details summary { | ||
font-size: var(--spectrum-font-size-200); | ||
line-height: var(--exlm-line-height-h4); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { generateAccordionDOM } from "../accordion/accordion.js"; | ||
Check failure on line 1 in blocks/accordion-group/accordion-group.js GitHub Actions / build
|
||
|
||
export default function decorate(block) { | ||
// each row is an accordion entry | ||
const accordions = [...block.children]; | ||
|
||
// loop through all accordion blocks | ||
[...accordions].forEach((accordion) => { | ||
// generate the accordion | ||
const accordionDOM = generateAccordionDOM(accordion); | ||
// empty the content ,keep root element with UE instrumentation | ||
accordion.textContent = ""; | ||
Check failure on line 12 in blocks/accordion-group/accordion-group.js GitHub Actions / build
|
||
// add block classes | ||
accordion.classList.add("accordion", "block"); | ||
Check failure on line 14 in blocks/accordion-group/accordion-group.js GitHub Actions / build
Check failure on line 14 in blocks/accordion-group/accordion-group.js GitHub Actions / build
Check failure on line 14 in blocks/accordion-group/accordion-group.js GitHub Actions / build
|
||
accordion.append(accordionDOM); | ||
}); | ||
|
||
// use same styling as shade-box from /docs | ||
block.classList.add("shade-box"); | ||
Check failure on line 19 in blocks/accordion-group/accordion-group.js GitHub Actions / build
|
||
try { | ||
openFunctionFAQ(block); | ||
Check failure on line 21 in blocks/accordion-group/accordion-group.js GitHub Actions / build
|
||
block.closest(".faq-view-more-logic") ? viewMoreLogicFAQ() : ""; | ||
Check failure on line 22 in blocks/accordion-group/accordion-group.js GitHub Actions / build
Check failure on line 22 in blocks/accordion-group/accordion-group.js GitHub Actions / build
Check failure on line 22 in blocks/accordion-group/accordion-group.js GitHub Actions / build
Check failure on line 22 in blocks/accordion-group/accordion-group.js GitHub Actions / build
Check failure on line 22 in blocks/accordion-group/accordion-group.js GitHub Actions / build
Check failure on line 22 in blocks/accordion-group/accordion-group.js GitHub Actions / build
Check failure on line 22 in blocks/accordion-group/accordion-group.js GitHub Actions / build
|
||
} catch (error) { | ||
console.error(error); | ||
Check warning on line 24 in blocks/accordion-group/accordion-group.js GitHub Actions / build
|
||
} | ||
} | ||
|
||
function openFunctionFAQ(block) { | ||
const titles = block.querySelectorAll("details summary"); | ||
|
||
titles.forEach(function (title) { | ||
Check warning on line 31 in blocks/accordion-group/accordion-group.js GitHub Actions / build
|
||
title.addEventListener("click", function () { | ||
Check warning on line 32 in blocks/accordion-group/accordion-group.js GitHub Actions / build
|
||
if(this.classList.contains('active')){ | ||
setTimeout(() => { | ||
this.closest("details").removeAttribute("open"); | ||
}, 1000); | ||
this.classList.remove("active"); | ||
}else{ | ||
titles.forEach(function (title) { | ||
Check warning on line 39 in blocks/accordion-group/accordion-group.js GitHub Actions / build
|
||
title.closest("details").removeAttribute("open"); | ||
title.classList.remove("active"); | ||
}); | ||
|
||
this.classList.toggle("active"); | ||
} | ||
}); | ||
}); | ||
|
||
} | ||
|
||
function viewMoreLogicFAQ() { | ||
document.querySelectorAll(".faq-section-wrapper.faq-view-more-logic").forEach((each) => { | ||
const allFAQSection = each.querySelectorAll(".accordion.block"); | ||
|
||
allFAQSection.forEach((eachFAQ, index) => { | ||
if (index == 5) { | ||
eachFAQ.classList.add("faq-blur"); | ||
} | ||
eachFAQ.classList.toggle("dp-none", index > 5); | ||
}); | ||
|
||
const buttonContainer = each.querySelector(".button-container"); | ||
if (buttonContainer) { | ||
const buttonText = buttonContainer.querySelector("a").textContent.trim(); | ||
buttonContainer.innerHTML = buttonText; | ||
viewMoreFAQ(each); | ||
} | ||
}); | ||
} | ||
function viewMoreFAQ(eachs) { | ||
const faqButtonContainer = eachs.querySelector(".faq-section-wrapper .button-container"); | ||
faqButtonContainer.addEventListener("click", function () { | ||
Check warning on line 72 in blocks/accordion-group/accordion-group.js GitHub Actions / build
|
||
const isViewMoreFAQ = this.textContent.toLowerCase() === "view more"; | ||
this.innerText = isViewMoreFAQ ? "View Less" : "View More"; | ||
|
||
eachs.querySelectorAll(".accordion.block").forEach((eachFAQ, index) => { | ||
if (index == 5) { | ||
var checkBlurClass = eachFAQ.classList.contains("faq-blur"); | ||
checkBlurClass ? eachFAQ.classList.remove("faq-blur") : eachFAQ.classList.add("faq-blur"); | ||
} | ||
eachFAQ.classList.toggle("dp-none", !isViewMoreFAQ && index > 5); | ||
}); | ||
}); | ||
} |