@paroicms/tiny-modal 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tiny-modal.css +18 -12
- package/dist/tiny-modal.d.ts +5 -3
- package/dist/tiny-modal.js +13 -8
- package/package.json +3 -3
- package/dist/tiny-modal.css.map +0 -1
package/dist/tiny-modal.css
CHANGED
|
@@ -2,14 +2,20 @@
|
|
|
2
2
|
.TinyModal {
|
|
3
3
|
background: transparent;
|
|
4
4
|
border: none;
|
|
5
|
-
margin:
|
|
6
|
-
max-width: none;
|
|
5
|
+
margin: auto;
|
|
7
6
|
padding: 0;
|
|
7
|
+
position: fixed;
|
|
8
|
+
overflow: visible;
|
|
9
|
+
max-width: 100vw;
|
|
10
|
+
max-height: 100vh;
|
|
8
11
|
}
|
|
9
12
|
.TinyModal::backdrop {
|
|
10
|
-
background-color:
|
|
13
|
+
background-color: rgba(34, 34, 34, 0.7333333333);
|
|
11
14
|
}
|
|
12
|
-
.TinyModal-
|
|
15
|
+
.TinyModal-body {
|
|
16
|
+
overflow: scroll;
|
|
17
|
+
}
|
|
18
|
+
.TinyModal-closeButton {
|
|
13
19
|
align-items: center;
|
|
14
20
|
background-color: #bbb;
|
|
15
21
|
border-radius: 50%;
|
|
@@ -21,20 +27,20 @@
|
|
|
21
27
|
justify-content: center;
|
|
22
28
|
line-height: 1;
|
|
23
29
|
position: absolute;
|
|
24
|
-
right:
|
|
25
|
-
top:
|
|
30
|
+
right: -30px;
|
|
31
|
+
top: -30px;
|
|
26
32
|
width: 40px;
|
|
27
33
|
z-index: 2;
|
|
28
34
|
}
|
|
29
|
-
.TinyModal-
|
|
35
|
+
.TinyModal-closeButton::before {
|
|
30
36
|
content: "×";
|
|
31
37
|
}
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
@media (max-width: 400px) {
|
|
39
|
+
.TinyModal-closeButton {
|
|
40
|
+
right: -18px;
|
|
41
|
+
}
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
.
|
|
44
|
+
.TinyModalHidden {
|
|
37
45
|
display: none !important;
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
/*# sourceMappingURL=tiny-modal.css.map */
|
package/dist/tiny-modal.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export interface TinyModal {
|
|
2
|
+
on: (event: "open" | "close", listener: TinyModalEventListener) => void;
|
|
2
3
|
open: () => void;
|
|
3
4
|
close: () => void;
|
|
4
|
-
on: (event: "open" | "close", listener: TinyModalEventListener) => void;
|
|
5
5
|
}
|
|
6
6
|
export type TinyModalEventListener = () => void;
|
|
7
7
|
export default function initializeTinyModal(options: {
|
|
8
|
-
openButton?: string | HTMLElement;
|
|
9
8
|
dialogContent: HTMLElement;
|
|
9
|
+
openButton?: string | HTMLElement;
|
|
10
|
+
modalClass?: string;
|
|
10
11
|
}): TinyModal;
|
|
11
12
|
export default function initializeTinyModal(options: {
|
|
12
|
-
openButton?: string | HTMLElement;
|
|
13
13
|
dialogContent: string;
|
|
14
|
+
openButton?: string | HTMLElement;
|
|
15
|
+
modalClass?: string;
|
|
14
16
|
}): TinyModal | undefined;
|
package/dist/tiny-modal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default function initializeTinyModal({ openButton, dialogContent, }) {
|
|
1
|
+
export default function initializeTinyModal({ openButton, dialogContent, modalClass, }) {
|
|
2
2
|
const openBtnEl = openButton
|
|
3
3
|
? typeof openButton === "string"
|
|
4
4
|
? document.querySelector(openButton)
|
|
@@ -8,17 +8,20 @@ export default function initializeTinyModal({ openButton, dialogContent, }) {
|
|
|
8
8
|
if (!contentEl)
|
|
9
9
|
return;
|
|
10
10
|
if (!(contentEl instanceof HTMLTemplateElement)) {
|
|
11
|
-
contentEl.classList.remove("
|
|
11
|
+
contentEl.classList.remove("TinyModalHidden");
|
|
12
12
|
}
|
|
13
13
|
const dialogEl = document.createElement("dialog");
|
|
14
14
|
dialogEl.classList.add("TinyModal");
|
|
15
|
+
if (modalClass) {
|
|
16
|
+
dialogEl.classList.add(modalClass);
|
|
17
|
+
}
|
|
15
18
|
const closeBtnEl = document.createElement("button");
|
|
16
|
-
closeBtnEl.classList.add("TinyModal-
|
|
19
|
+
closeBtnEl.classList.add("TinyModal-closeButton");
|
|
17
20
|
dialogEl.appendChild(closeBtnEl);
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
dialogEl.appendChild(
|
|
21
|
+
const bodyEl = document.createElement("div");
|
|
22
|
+
bodyEl.classList.add("TinyModal-body");
|
|
23
|
+
bodyEl.appendChild(contentEl instanceof HTMLTemplateElement ? contentEl.content.cloneNode(true) : contentEl);
|
|
24
|
+
dialogEl.appendChild(bodyEl);
|
|
22
25
|
document.body.appendChild(dialogEl);
|
|
23
26
|
const eventListeners = new Map();
|
|
24
27
|
function on(event, listener) {
|
|
@@ -35,6 +38,7 @@ export default function initializeTinyModal({ openButton, dialogContent, }) {
|
|
|
35
38
|
function open() {
|
|
36
39
|
dialogEl.showModal();
|
|
37
40
|
document.body.style.overflow = "hidden";
|
|
41
|
+
document.documentElement.style.overflow = "hidden";
|
|
38
42
|
trigger("open");
|
|
39
43
|
}
|
|
40
44
|
function close() {
|
|
@@ -43,7 +47,8 @@ export default function initializeTinyModal({ openButton, dialogContent, }) {
|
|
|
43
47
|
openBtnEl?.addEventListener("click", open);
|
|
44
48
|
closeBtnEl.addEventListener("click", close);
|
|
45
49
|
dialogEl.addEventListener("close", () => {
|
|
46
|
-
document.body.style.overflow
|
|
50
|
+
document.body.style.removeProperty("overflow");
|
|
51
|
+
document.documentElement.style.removeProperty("overflow");
|
|
47
52
|
trigger("close");
|
|
48
53
|
});
|
|
49
54
|
return { open, close, on };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paroicms/tiny-modal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Tiny modal library for creating modal dialogs",
|
|
5
5
|
"author": "Paroi Team",
|
|
6
6
|
"repository": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"build": "tsc && npm run scss",
|
|
13
13
|
"clear": "rimraf dist/*",
|
|
14
14
|
"dev": "tsc --watch --preserveWatchOutput",
|
|
15
|
-
"scss": "sass src/tiny-modal.scss dist/tiny-modal.css",
|
|
15
|
+
"scss": "sass src/tiny-modal.scss dist/tiny-modal.css --no-source-map",
|
|
16
16
|
"scss:watch": "sass --watch src/tiny-modal.scss dist/tiny-modal.css"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"main": "dist/tiny-modal.js",
|
|
25
25
|
"typings": "dist/tiny-modal.d.ts",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"sass": "~1.
|
|
27
|
+
"sass": "~1.85.1",
|
|
28
28
|
"rimraf": "~6.0.1",
|
|
29
29
|
"typescript": "~5.8.2",
|
|
30
30
|
"@paroicms/public-anywhere-lib": "0.19.0"
|
package/dist/tiny-modal.css.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../src/tiny-modal.scss"],"names":[],"mappings":";AAAA;EACE;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EAEE;;;AAKN;EACE","file":"tiny-modal.css"}
|