@travelopia/web-components 0.0.7 → 0.0.9
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/declarations.d.ts +42 -0
- package/dist/modal/index.js +1 -1
- package/dist/modal/index.js.map +1 -1
- package/package.json +5 -8
- package/definitions.d.ts +0 -8
- package/src/modal/README.md +0 -35
- package/src/modal/index.html +0 -35
- package/src/modal/index.ts +0 -16
- package/src/modal/style.scss +0 -34
- package/src/modal/tp-modal-close.ts +0 -25
- package/src/modal/tp-modal.ts +0 -46
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TP Modal Close.
|
|
3
|
+
*/
|
|
4
|
+
export class TPModalCloseElement extends HTMLElement {
|
|
5
|
+
/**
|
|
6
|
+
* Connected callback.
|
|
7
|
+
*/
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Close the modal.
|
|
11
|
+
*/
|
|
12
|
+
closeModal(): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* TP Modal.
|
|
17
|
+
*/
|
|
18
|
+
export class TPModalElement extends HTMLElement {
|
|
19
|
+
/**
|
|
20
|
+
* Constructor.
|
|
21
|
+
*/
|
|
22
|
+
constructor();
|
|
23
|
+
/**
|
|
24
|
+
* Connected callback.
|
|
25
|
+
*/
|
|
26
|
+
connectedCallback(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Open the modal.
|
|
29
|
+
*/
|
|
30
|
+
open(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Close the modal.
|
|
33
|
+
*/
|
|
34
|
+
close(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Handle when the component is clicked.
|
|
37
|
+
*
|
|
38
|
+
* @param {Event} e Event.
|
|
39
|
+
*/
|
|
40
|
+
handleClick(e: Event): void;
|
|
41
|
+
}
|
|
42
|
+
|
package/dist/modal/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";class e extends HTMLElement{constructor(){var e;super(),null===(e=document.querySelector("body"))||void 0===e||e.appendChild(this)}connectedCallback(){this.addEventListener("click",this.handleClick.bind(this))}open(){this.setAttribute("open","yes")}close(){this.removeAttribute("open")}handleClick(e){e.target===this&&"yes"===this.getAttribute("overlay-click-close")&&(e.preventDefault(),e.stopPropagation(),this.close())}}class t extends HTMLElement{connectedCallback(){const e=this.querySelector("button");null==e||e.addEventListener("click",this.closeModal.bind(this))}closeModal(){const e=this.closest("tp-modal");null==e||e.close()}}customElements.define("tp-modal",e),customElements.define("tp-modal-close",t)})();
|
|
1
|
+
(()=>{"use strict";class e extends HTMLElement{constructor(){var e;super(),null===(e=document.querySelector("body"))||void 0===e||e.appendChild(this)}connectedCallback(){this.addEventListener("click",this.handleClick.bind(this))}open(){this.setAttribute("open","yes"),this.dispatchEvent(new CustomEvent("open",{bubbles:!0}))}close(){this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{bubbles:!0}))}handleClick(e){e.target===this&&"yes"===this.getAttribute("overlay-click-close")&&(e.preventDefault(),e.stopPropagation(),this.close())}}class t extends HTMLElement{connectedCallback(){const e=this.querySelector("button");null==e||e.addEventListener("click",this.closeModal.bind(this))}closeModal(){const e=this.closest("tp-modal");null==e||e.close()}}customElements.define("tp-modal",e),customElements.define("tp-modal-close",t)})();
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/modal/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dist/modal/index.js","mappings":"mBAGO,MAAMA,UAAuBC,YAInC,WAAAC,G,MACCC,QACgC,QAAhC,EAAAC,SAASC,cAAe,eAAQ,SAAEC,YAAaC,KAChD,CAKA,iBAAAC,GACCD,KAAKE,iBAAkB,QAASF,KAAKG,YAAYC,KAAMJ,MACxD,CAKA,IAAAK,GACCL,KAAKM,aAAc,OAAQ,
|
|
1
|
+
{"version":3,"file":"dist/modal/index.js","mappings":"mBAGO,MAAMA,UAAuBC,YAInC,WAAAC,G,MACCC,QACgC,QAAhC,EAAAC,SAASC,cAAe,eAAQ,SAAEC,YAAaC,KAChD,CAKA,iBAAAC,GACCD,KAAKE,iBAAkB,QAASF,KAAKG,YAAYC,KAAMJ,MACxD,CAKA,IAAAK,GACCL,KAAKM,aAAc,OAAQ,OAC3BN,KAAKO,cAAe,IAAIC,YAAa,OAAQ,CAAEC,SAAS,IACzD,CAKA,KAAAC,GACCV,KAAKW,gBAAiB,QACtBX,KAAKO,cAAe,IAAIC,YAAa,QAAS,CAAEC,SAAS,IAC1D,CAOA,WAAAN,CAAaS,GACPA,EAAEC,SAAWb,MAAQ,QAAUA,KAAKc,aAAc,yBACtDF,EAAEG,iBACFH,EAAEI,kBACFhB,KAAKU,QAEP,ECtCM,MAAMO,UAA4BvB,YAIxC,iBAAAO,GACC,MAAMiB,EAAmClB,KAAKF,cAAe,UAC7DoB,SAAAA,EAAQhB,iBAAkB,QAASF,KAAKmB,WAAWf,KAAMJ,MAC1D,CAKA,UAAAmB,GACC,MAAMC,EAA+BpB,KAAKqB,QAAS,YACnDD,SAAAA,EAAOV,OACR,ECTDY,eAAeC,OAAQ,WAAY9B,GACnC6B,eAAeC,OAAQ,iBAAkBN,E","sources":["webpack://@travelopia/web-components/./src/modal/tp-modal.ts","webpack://@travelopia/web-components/./src/modal/tp-modal-close.ts","webpack://@travelopia/web-components/./src/modal/index.ts"],"sourcesContent":["/**\n * TP Modal.\n */\nexport class TPModalElement extends HTMLElement {\n\t/**\n\t * Constructor.\n\t */\n\tconstructor() {\n\t\tsuper();\n\t\tdocument.querySelector( 'body' )?.appendChild( this );\n\t}\n\n\t/**\n\t * Connected callback.\n\t */\n\tconnectedCallback(): void {\n\t\tthis.addEventListener( 'click', this.handleClick.bind( this ) );\n\t}\n\n\t/**\n\t * Open the modal.\n\t */\n\topen(): void {\n\t\tthis.setAttribute( 'open', 'yes' );\n\t\tthis.dispatchEvent( new CustomEvent( 'open', { bubbles: true } ) );\n\t}\n\n\t/**\n\t * Close the modal.\n\t */\n\tclose(): void {\n\t\tthis.removeAttribute( 'open' );\n\t\tthis.dispatchEvent( new CustomEvent( 'close', { bubbles: true } ) );\n\t}\n\n\t/**\n\t * Handle when the component is clicked.\n\t *\n\t * @param {Event} e Event.\n\t */\n\thandleClick( e: Event ): void {\n\t\tif ( e.target === this && 'yes' === this.getAttribute( 'overlay-click-close' ) ) {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\tthis.close();\n\t\t}\n\t}\n}\n","/**\n * Internal dependencies.\n */\nimport { TPModalElement } from './tp-modal';\n\n/**\n * TP Modal Close.\n */\nexport class TPModalCloseElement extends HTMLElement {\n\t/**\n\t * Connected callback.\n\t */\n\tconnectedCallback(): void {\n\t\tconst button: HTMLButtonElement | null = this.querySelector( 'button' );\n\t\tbutton?.addEventListener( 'click', this.closeModal.bind( this ) );\n\t}\n\n\t/**\n\t * Close the modal.\n\t */\n\tcloseModal(): void {\n\t\tconst modal: TPModalElement | null = this.closest( 'tp-modal' );\n\t\tmodal?.close();\n\t}\n}\n","/**\n * Styles.\n */\nimport './style.scss';\n\n/**\n * Components.\n */\nimport { TPModalElement } from './tp-modal';\nimport { TPModalCloseElement } from './tp-modal-close';\n\n/**\n * Register Components.\n */\ncustomElements.define( 'tp-modal', TPModalElement );\ncustomElements.define( 'tp-modal-close', TPModalCloseElement );\n"],"names":["TPModalElement","HTMLElement","constructor","super","document","querySelector","appendChild","this","connectedCallback","addEventListener","handleClick","bind","open","setAttribute","dispatchEvent","CustomEvent","bubbles","close","removeAttribute","e","target","getAttribute","preventDefault","stopPropagation","TPModalCloseElement","button","closeModal","modal","closest","customElements","define"],"sourceRoot":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travelopia/web-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Accessible web components for the modern web",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
5
8
|
"scripts": {
|
|
6
9
|
"build": "webpack --config ./webpack.config.js --mode production --env=production",
|
|
7
10
|
"dev": "webpack --config ./webpack.config.js --mode production --env=development --watch",
|
|
@@ -24,17 +27,11 @@
|
|
|
24
27
|
"postcss-loader": "^7.3.3",
|
|
25
28
|
"sass": "^1.69.5",
|
|
26
29
|
"sass-loader": "^13.3.2",
|
|
27
|
-
"terser-webpack-plugin": "^5.3.9",
|
|
28
30
|
"ts-loader": "^9.5.0",
|
|
29
31
|
"typescript": "^5.2.2",
|
|
30
32
|
"webpack": "^5.89.0",
|
|
31
33
|
"webpack-cli": "^5.1.4",
|
|
32
34
|
"webpack-notifier": "^1.15.0"
|
|
33
35
|
},
|
|
34
|
-
"
|
|
35
|
-
"./*": "./dist/*",
|
|
36
|
-
"./definitions.d.ts": "./definitions.d.ts",
|
|
37
|
-
"./package.json": "./package.json"
|
|
38
|
-
},
|
|
39
|
-
"types": "./definitions.d.ts"
|
|
36
|
+
"types": "./dist/declarations.d.ts"
|
|
40
37
|
}
|
package/definitions.d.ts
DELETED
package/src/modal/README.md
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# Modal
|
|
2
|
-
|
|
3
|
-
<table width="100%">
|
|
4
|
-
<tr>
|
|
5
|
-
<td align="left" width="70%">
|
|
6
|
-
<p>Built by the super talented team at <strong><a href="https://www.travelopia.com/work-with-us/">Travelopia</a></strong>.</p>
|
|
7
|
-
</td>
|
|
8
|
-
<td align="center" width="30%">
|
|
9
|
-
<img src="https://www.travelopia.com/wp-content/themes/travelopia/assets/svg/logo-travelopia-circle.svg" width="50" />
|
|
10
|
-
</td>
|
|
11
|
-
</tr>
|
|
12
|
-
</table>
|
|
13
|
-
|
|
14
|
-
## Sample Usage
|
|
15
|
-
|
|
16
|
-
This is a super minimal modal that is designed to be highly extendable.
|
|
17
|
-
|
|
18
|
-
Example:
|
|
19
|
-
|
|
20
|
-
```html
|
|
21
|
-
<tp-modal overlay-click-close="yes">
|
|
22
|
-
<tp-modal-close>
|
|
23
|
-
<button>Close</button> <-- There must be a button inside inside this component.
|
|
24
|
-
</tp-modal-close>
|
|
25
|
-
<tp-modal-content>
|
|
26
|
-
<p>Any modal content here.</p>
|
|
27
|
-
</tp-modal-content>
|
|
28
|
-
</tp-modal>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Attributes
|
|
32
|
-
|
|
33
|
-
| Attribute | Required | Values | Notes |
|
|
34
|
-
|----------------------|----------|--------|----------------------------------------------|
|
|
35
|
-
| overlay-click-close | No | `yes` | Closes the modal when the overlay is clicked |
|
package/src/modal/index.html
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
|
|
6
|
-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
7
|
-
<title>Web Component: Modal</title>
|
|
8
|
-
|
|
9
|
-
<link rel="stylesheet" href="../../dist/modal/style.css" media="all">
|
|
10
|
-
<script type="module" src="../../dist/modal/index.js"></script>
|
|
11
|
-
</head>
|
|
12
|
-
<body>
|
|
13
|
-
<main>
|
|
14
|
-
<button id="open-modal">Open Modal</button>
|
|
15
|
-
<tp-modal id="my-modal" overlay-click-close="yes">
|
|
16
|
-
<tp-modal-close>
|
|
17
|
-
<button>Close</button>
|
|
18
|
-
</tp-modal-close>
|
|
19
|
-
<tp-modal-content>
|
|
20
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
21
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
22
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
23
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
24
|
-
</tp-modal-content>
|
|
25
|
-
</tp-modal>
|
|
26
|
-
</main>
|
|
27
|
-
|
|
28
|
-
<script>
|
|
29
|
-
const button = document.getElementById( 'open-modal' );
|
|
30
|
-
const modal = document.getElementById( 'my-modal' );
|
|
31
|
-
|
|
32
|
-
button.addEventListener( 'click', () => modal.open() );
|
|
33
|
-
</script>
|
|
34
|
-
</body>
|
|
35
|
-
</html>
|
package/src/modal/index.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Styles.
|
|
3
|
-
*/
|
|
4
|
-
import './style.scss';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Components.
|
|
8
|
-
*/
|
|
9
|
-
import { TPModalElement } from './tp-modal';
|
|
10
|
-
import { TPModalCloseElement } from './tp-modal-close';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Register Components.
|
|
14
|
-
*/
|
|
15
|
-
customElements.define( 'tp-modal', TPModalElement );
|
|
16
|
-
customElements.define( 'tp-modal-close', TPModalCloseElement );
|
package/src/modal/style.scss
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
tp-modal {
|
|
2
|
-
display: none;
|
|
3
|
-
background-color: rgba(#000, 0.5);
|
|
4
|
-
backdrop-filter: blur(2px);
|
|
5
|
-
position: fixed;
|
|
6
|
-
height: 100%;
|
|
7
|
-
width: 100%;
|
|
8
|
-
left: 0;
|
|
9
|
-
top: 0;
|
|
10
|
-
z-index: 99;
|
|
11
|
-
max-width: 100%;
|
|
12
|
-
overflow-y: auto;
|
|
13
|
-
padding: 20px;
|
|
14
|
-
box-sizing: border-box;
|
|
15
|
-
|
|
16
|
-
&[open] {
|
|
17
|
-
display: flex;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&-close {
|
|
21
|
-
position: absolute;
|
|
22
|
-
top: 20px;
|
|
23
|
-
right: 20px;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&-content {
|
|
27
|
-
display: block;
|
|
28
|
-
min-width: 0;
|
|
29
|
-
margin: auto;
|
|
30
|
-
padding: 20px;
|
|
31
|
-
background-color: #fff;
|
|
32
|
-
max-width: 80ch;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies.
|
|
3
|
-
*/
|
|
4
|
-
import { TPModalElement } from './tp-modal';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* TP Modal Close.
|
|
8
|
-
*/
|
|
9
|
-
export class TPModalCloseElement extends HTMLElement {
|
|
10
|
-
/**
|
|
11
|
-
* Connected callback.
|
|
12
|
-
*/
|
|
13
|
-
connectedCallback(): void {
|
|
14
|
-
const button: HTMLButtonElement | null = this.querySelector( 'button' );
|
|
15
|
-
button?.addEventListener( 'click', this.closeModal.bind( this ) );
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Close the modal.
|
|
20
|
-
*/
|
|
21
|
-
closeModal(): void {
|
|
22
|
-
const modal: TPModalElement | null = this.closest( 'tp-modal' );
|
|
23
|
-
modal?.close();
|
|
24
|
-
}
|
|
25
|
-
}
|
package/src/modal/tp-modal.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TP Modal.
|
|
3
|
-
*/
|
|
4
|
-
export class TPModalElement extends HTMLElement {
|
|
5
|
-
/**
|
|
6
|
-
* Constructor.
|
|
7
|
-
*/
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
document.querySelector( 'body' )?.appendChild( this );
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Connected callback.
|
|
15
|
-
*/
|
|
16
|
-
connectedCallback(): void {
|
|
17
|
-
this.addEventListener( 'click', this.handleClick.bind( this ) );
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Open the modal.
|
|
22
|
-
*/
|
|
23
|
-
open(): void {
|
|
24
|
-
this.setAttribute( 'open', 'yes' );
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Close the modal.
|
|
29
|
-
*/
|
|
30
|
-
close(): void {
|
|
31
|
-
this.removeAttribute( 'open' );
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Handle when the component is clicked.
|
|
36
|
-
*
|
|
37
|
-
* @param {Event} e Event.
|
|
38
|
-
*/
|
|
39
|
-
handleClick( e: Event ): void {
|
|
40
|
-
if ( e.target === this && 'yes' === this.getAttribute( 'overlay-click-close' ) ) {
|
|
41
|
-
e.preventDefault();
|
|
42
|
-
e.stopPropagation();
|
|
43
|
-
this.close();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|