feat(components): add offcanvas component
This commit is contained in:
parent
e0ed5a5ddd
commit
c47a2eff89
14 changed files with 233 additions and 129 deletions
21
packages/components/src/offcanvas/index.ts
Normal file
21
packages/components/src/offcanvas/index.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { qs, qsa } from "../utils";
|
||||
|
||||
window.onload = () => {
|
||||
qsa(".msp-offcanvas-toggle").forEach((item) => {
|
||||
item.addEventListener("click", () => {
|
||||
const target = item.dataset.mspTarget;
|
||||
|
||||
if (!target) {
|
||||
throw new Error("No target provided");
|
||||
}
|
||||
|
||||
const targetElement = qs(target);
|
||||
|
||||
if (!targetElement) {
|
||||
throw new Error("No target found");
|
||||
}
|
||||
|
||||
targetElement.classList.toggle("show");
|
||||
});
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue