generated from 5t3ph/eleventy-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
panels.min.js
1 lines (1 loc) · 1.39 KB
/
panels.min.js
1
(()=>{document.querySelectorAll(".css-support-panel-container").forEach((e=>{const t=e.querySelector(".css-support-button").getAttribute("aria-controls"),s=document.getElementById(t);e.querySelector("code").style.pointerEvents="none",e.appendChild(s)}));const e=e=>{e.closest(".css-support-panel-container").querySelector("button").setAttribute("aria-expanded","false"),e.setAttribute("hidden",""),e.classList.remove("css-support-panel--left"),e.classList.remove("css-support-panel--right"),document.removeEventListener("click",s),document.removeEventListener("keyup",t)},t=t=>{const s=t.target,n=document.querySelector(".css-support-panel:not([hidden])");n&&("Escape"===t.key&&e(n),"Tab"!==t.key||s.closest(".css-support-panel")||e(n))},s=t=>{const s=t.target,n=document.querySelector(".css-support-panel:not([hidden])");n&&!s.closest(".css-support-panel")&&e(n)},n=n=>{const o=n.getAttribute("aria-controls"),c=document.getElementById(o),r=document.querySelector(`.css-support-panel:not([hidden]):not(#${o}`);r&&e(r),n.setAttribute("aria-expanded",!0),c.removeAttribute("hidden"),(e=>{const t=e.getBoundingClientRect();t.left<0&&e.classList.add("css-support-panel--left"),t.right>window.innerWidth&&e.classList.add("css-support-panel--right")})(c),document.addEventListener("click",s),document.addEventListener("keyup",t)};document.addEventListener("click",(e=>{const t=e.target;t.matches(".css-support-button")&&n(t)}))})();