@travelopia/web-components 0.0.8 → 0.1.0

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/README.md CHANGED
@@ -7,10 +7,14 @@ Accessible web components for the modern web.
7
7
  <table width="100%">
8
8
  <tr>
9
9
  <td align="left" width="70%">
10
- <p>Built by the super talented team at <strong><a href="https://www.travelopia.com/work-with-us/">Travelopia</a></strong>.</p>
10
+ <p>Built by the super talented team at <strong><a href="https://www.travelopia.com/work-with-us/">Travelopia</a></strong>.</p>
11
11
  </td>
12
12
  <td align="center" width="30%">
13
13
  <img src="https://www.travelopia.com/wp-content/themes/travelopia/assets/svg/logo-travelopia-circle.svg" width="50" />
14
14
  </td>
15
15
  </tr>
16
16
  </table>
17
+
18
+ ### Installation
19
+
20
+ `npm i @travelopia/web-components`
@@ -0,0 +1,229 @@
1
+ /**
2
+ * TP Slider.
3
+ */
4
+ export class TPSliderElement extends HTMLElement {
5
+ /**
6
+ * Properties.
7
+ */
8
+ protected touchStartX: number;
9
+ /**
10
+ * Constructor.
11
+ */
12
+ constructor();
13
+ /**
14
+ * Get observed attributes.
15
+ *
16
+ * @return {Array} List of observed attributes.
17
+ */
18
+ static get observedAttributes(): string[];
19
+ /**
20
+ * Attribute changed callback.
21
+ *
22
+ * @param {string} name Attribute name.
23
+ * @param {string} oldValue Old value.
24
+ * @param {string} newValue New value.
25
+ */
26
+ attributeChangedCallback(name?: string, oldValue?: string, newValue?: string): void;
27
+ /**
28
+ * Get current slide index.
29
+ *
30
+ * @return {number} Current slide index.
31
+ */
32
+ get currentSlideIndex(): number;
33
+ /**
34
+ * Set current slide index.
35
+ *
36
+ * @param {number} index Slide index.
37
+ */
38
+ set currentSlideIndex(index: number);
39
+ /**
40
+ * Get total number of slides.
41
+ *
42
+ * @return {number} Total slides.
43
+ */
44
+ getTotalSlides(): number;
45
+ /**
46
+ * Navigate to the next slide.
47
+ */
48
+ next(): void;
49
+ /**
50
+ * Navigate to the previous slide.
51
+ */
52
+ previous(): void;
53
+ /**
54
+ * Get current slide index.
55
+ *
56
+ * @return {number} Current slide index.
57
+ */
58
+ getCurrentSlide(): number;
59
+ /**
60
+ * Set the current slide index.
61
+ *
62
+ * @param {number} index Slide index.
63
+ */
64
+ setCurrentSlide(index: number): void;
65
+ /**
66
+ * Slide to the current slide.
67
+ *
68
+ * @protected
69
+ */
70
+ protected slide(): void;
71
+ /**
72
+ * Update stuff when any attribute has changed.
73
+ * Example: Update subcomponents.
74
+ */
75
+ update(): void;
76
+ /**
77
+ * Update the height of the slider based on current slide.
78
+ */
79
+ updateHeight(): void;
80
+ /**
81
+ * Resize the slider when the window is resized.
82
+ *
83
+ * @protected
84
+ */
85
+ protected handleResize(): void;
86
+ /**
87
+ * Detect touch start event, and store the starting location.
88
+ *
89
+ * @param {Event} e Touch event.
90
+ *
91
+ * @protected
92
+ */
93
+ protected handleTouchStart(e: TouchEvent): void;
94
+ /**
95
+ * Detect touch end event, and check if it was a left or right swipe.
96
+ *
97
+ * @param {Event} e Touch event.
98
+ *
99
+ * @protected
100
+ */
101
+ protected handleTouchEnd(e: TouchEvent): void;
102
+ }
103
+
104
+ /**
105
+ * TP Slider Nav Item.
106
+ */
107
+ export class TPSliderNavItemElement extends HTMLElement {
108
+ /**
109
+ * Connected callback.
110
+ */
111
+ connectedCallback(): void;
112
+ /**
113
+ * Handle when the button is clicked.
114
+ */
115
+ handleClick(): void;
116
+ /**
117
+ * Get index of this item inside the navigation.
118
+ *
119
+ * @return {number} Index.
120
+ */
121
+ getIndex(): number;
122
+ }
123
+
124
+ /**
125
+ * TP Slider Arrow.
126
+ */
127
+ export class TPSliderArrowElement extends HTMLElement {
128
+ /**
129
+ * Connected callback.
130
+ */
131
+ connectedCallback(): void;
132
+ /**
133
+ * Handle when the button is clicked.
134
+ */
135
+ handleClick(): void;
136
+ }
137
+
138
+ /**
139
+ * TP Modal.
140
+ */
141
+ export class TPModalElement extends HTMLElement {
142
+ /**
143
+ * Constructor.
144
+ */
145
+ constructor();
146
+ /**
147
+ * Connected callback.
148
+ */
149
+ connectedCallback(): void;
150
+ /**
151
+ * Open the modal.
152
+ */
153
+ open(): void;
154
+ /**
155
+ * Close the modal.
156
+ */
157
+ close(): void;
158
+ /**
159
+ * Handle when the component is clicked.
160
+ *
161
+ * @param {Event} e Event.
162
+ */
163
+ handleClick(e: Event): void;
164
+ }
165
+
166
+ /**
167
+ * TP Modal Close.
168
+ */
169
+ export class TPModalCloseElement extends HTMLElement {
170
+ /**
171
+ * Connected callback.
172
+ */
173
+ connectedCallback(): void;
174
+ /**
175
+ * Close the modal.
176
+ */
177
+ closeModal(): void;
178
+ }
179
+
180
+ /**
181
+ * TP Slider Slides.
182
+ */
183
+ export class TPSliderSlidesElement extends HTMLElement {
184
+ }
185
+
186
+ /**
187
+ * TP Slider Slide.
188
+ */
189
+ export class TPSliderSlideElement extends HTMLElement {
190
+ }
191
+
192
+ /**
193
+ * TP Slider Nav.
194
+ */
195
+ export class TPSliderNavElement extends HTMLElement {
196
+ }
197
+
198
+ /**
199
+ * TP Slider Count.
200
+ */
201
+ export class TPSliderCountElement extends HTMLElement {
202
+ /**
203
+ * Get observed attributes.
204
+ *
205
+ * @return {Array} Observed attributes.
206
+ */
207
+ static get observedAttributes(): string[];
208
+ /**
209
+ * Get format.
210
+ *
211
+ * @return {string} Format.
212
+ */
213
+ get format(): string;
214
+ /**
215
+ * Set format.
216
+ *
217
+ * @param {string} format Format.
218
+ */
219
+ set format(format: string);
220
+ /**
221
+ * Attribute changed callback.
222
+ */
223
+ attributeChangedCallback(): void;
224
+ /**
225
+ * Update component.
226
+ */
227
+ update(): void;
228
+ }
229
+
@@ -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
@@ -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,MAC5B,CAKA,KAAAC,GACCP,KAAKQ,gBAAiB,OACvB,CAOA,WAAAL,CAAaM,GACPA,EAAEC,SAAWV,MAAQ,QAAUA,KAAKW,aAAc,yBACtDF,EAAEG,iBACFH,EAAEI,kBACFb,KAAKO,QAEP,ECpCM,MAAMO,UAA4BpB,YAIxC,iBAAAO,GACC,MAAMc,EAAmCf,KAAKF,cAAe,UAC7DiB,SAAAA,EAAQb,iBAAkB,QAASF,KAAKgB,WAAWZ,KAAMJ,MAC1D,CAKA,UAAAgB,GACC,MAAMC,EAA+BjB,KAAKkB,QAAS,YACnDD,SAAAA,EAAOV,OACR,ECTDY,eAAeC,OAAQ,WAAY3B,GACnC0B,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}\n\n\t/**\n\t * Close the modal.\n\t */\n\tclose(): void {\n\t\tthis.removeAttribute( 'open' );\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","close","removeAttribute","e","target","getAttribute","preventDefault","stopPropagation","TPModalCloseElement","button","closeModal","modal","closest","customElements","define"],"sourceRoot":""}
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":""}
@@ -0,0 +1,2 @@
1
+ (()=>{"use strict";class t extends HTMLElement{constructor(){super(),this.touchStartX=0,this.getAttribute("current-slide")||this.setAttribute("current-slide","1"),this.slide(),this.setAttribute("initialized","yes"),window.addEventListener("resize",this.handleResize.bind(this)),this.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.addEventListener("touchend",this.handleTouchEnd.bind(this))}static get observedAttributes(){return["current-slide","flexible-height","infinite"]}attributeChangedCallback(t="",e="",i=""){"current-slide"===t&&e!==i&&(this.slide(),this.dispatchEvent(new CustomEvent("slide-complete",{bubbles:!0}))),this.update()}get currentSlideIndex(){var t;return parseInt(null!==(t=this.getAttribute("current-slide"))&&void 0!==t?t:"1")}set currentSlideIndex(t){this.setCurrentSlide(t)}getTotalSlides(){const t=this.querySelectorAll("tp-slider-slide");return t?t.length:0}next(){const t=this.getTotalSlides();this.currentSlideIndex>=t?"yes"===this.getAttribute("infinite")&&this.setCurrentSlide(1):this.setCurrentSlide(this.currentSlideIndex+1)}previous(){this.currentSlideIndex<=1?"yes"===this.getAttribute("infinite")&&this.setCurrentSlide(this.getTotalSlides()):this.setCurrentSlide(this.currentSlideIndex-1)}getCurrentSlide(){return this.currentSlideIndex}setCurrentSlide(t){t>this.getTotalSlides()||t<=0||(this.dispatchEvent(new CustomEvent("slide-set",{bubbles:!0})),this.setAttribute("current-slide",t.toString()))}slide(){if("yes"===this.getAttribute("disabled"))return;const t=this.querySelector("tp-slider-slides"),e=this.querySelectorAll("tp-slider-slide");t&&e&&(this.updateHeight(),t.style.left=`-${this.offsetWidth*(this.currentSlideIndex-1)}px`)}update(){const t=this.querySelectorAll("tp-slider-nav-item"),e=this.querySelector("tp-slider-count"),i=this.querySelector('tp-slider-arrow[direction="previous"]'),s=this.querySelector('tp-slider-arrow[direction="next"]'),r=this.querySelectorAll("tp-slider-slide");null==r||r.forEach(((t,e)=>{this.currentSlideIndex-1===e?t.setAttribute("active","yes"):t.removeAttribute("active")})),t&&t.forEach(((t,e)=>{this.currentSlideIndex-1===e?t.setAttribute("current","yes"):t.removeAttribute("current")})),e&&(e.setAttribute("current",this.getCurrentSlide().toString()),e.setAttribute("total",this.getTotalSlides().toString())),"yes"!==this.getAttribute("infinite")?(this.getCurrentSlide()===this.getTotalSlides()?null==s||s.setAttribute("disabled","yes"):null==s||s.removeAttribute("disabled"),1===this.getCurrentSlide()?null==i||i.setAttribute("disabled","yes"):null==i||i.removeAttribute("disabled")):(null==s||s.removeAttribute("disabled"),null==i||i.removeAttribute("disabled"))}updateHeight(){const t=this.querySelector("tp-slider-slides");if(!t)return;if("yes"!==this.getAttribute("flexible-height"))return void t.style.removeProperty("height");const e=this.querySelectorAll("tp-slider-slide");if(!e)return;const i=e[this.currentSlideIndex-1].scrollHeight;t.style.height=`${i}px`}handleResize(){this.setAttribute("resizing","yes"),this.slide();const t=this;setTimeout((function(){t.removeAttribute("resizing")}),10)}handleTouchStart(t){"yes"===this.getAttribute("swipe")&&(this.touchStartX=t.touches[0].clientX)}handleTouchEnd(t){if("yes"!==this.getAttribute("swipe"))return;const e=t.changedTouches[0].clientX-this.touchStartX;e>0?this.previous():e<0&&this.next()}}class e extends HTMLElement{}class i extends HTMLElement{}class s extends HTMLElement{connectedCallback(){var t;null===(t=this.querySelector("button"))||void 0===t||t.addEventListener("click",this.handleClick.bind(this))}handleClick(){if("yes"===this.getAttribute("disabled"))return;const t=this.closest("tp-slider");t&&("previous"===this.getAttribute("direction")?t.previous():"next"===this.getAttribute("direction")&&t.next())}}class r extends HTMLElement{}class l extends HTMLElement{connectedCallback(){var t;null===(t=this.querySelector("button"))||void 0===t||t.addEventListener("click",this.handleClick.bind(this))}handleClick(){const t=this.closest("tp-slider");t&&t.setCurrentSlide(this.getIndex())}getIndex(){var t,e;if(this.getAttribute("index"))return parseInt(null!==(t=this.getAttribute("index"))&&void 0!==t?t:"0");const i=this.closest("tp-slider-nav");return Array.from(null!==(e=null==i?void 0:i.children)&&void 0!==e?e:[]).indexOf(this)+1}}class n extends HTMLElement{static get observedAttributes(){return["current","total","format"]}get format(){var t;return null!==(t=this.getAttribute("format"))&&void 0!==t?t:"$current / $total"}set format(t){this.setAttribute("format",t)}attributeChangedCallback(){this.update()}update(){var t,e;this.innerHTML=this.format.replace("$current",null!==(t=this.getAttribute("current"))&&void 0!==t?t:"").replace("$total",null!==(e=this.getAttribute("total"))&&void 0!==e?e:"")}}customElements.define("tp-slider",t),customElements.define("tp-slider-slides",e),customElements.define("tp-slider-slide",i),customElements.define("tp-slider-arrow",s),customElements.define("tp-slider-nav",r),customElements.define("tp-slider-nav-item",l),customElements.define("tp-slider-count",n)})();
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dist/slider/index.js","mappings":"mBAYO,MAAMA,UAAwBC,YASpC,WAAAC,GACCC,QANS,KAAAC,YAAsB,EASxBC,KAAKC,aAAc,kBACzBD,KAAKE,aAAc,gBAAiB,KAIrCF,KAAKG,QACLH,KAAKE,aAAc,cAAe,OAGlCE,OAAOC,iBAAkB,SAAUL,KAAKM,aAAaC,KAAMP,OAC3DA,KAAKK,iBAAkB,aAAcL,KAAKQ,iBAAiBD,KAAMP,OACjEA,KAAKK,iBAAkB,WAAYL,KAAKS,eAAeF,KAAMP,MAC9D,CAOA,6BAAWU,GACV,MAAO,CAAE,gBAAiB,kBAAmB,WAC9C,CASA,wBAAAC,CAA0BC,EAAe,GAAIC,EAAmB,GAAIC,EAAmB,IACjF,kBAAoBF,GAAQC,IAAaC,IAC7Cd,KAAKG,QACLH,KAAKe,cAAe,IAAIC,YAAa,iBAAkB,CAAEC,SAAS,MAGnEjB,KAAKkB,QACN,CAOA,qBAAIC,G,M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A5D,GACCX,KAAKkB,QACN,CAKA,MAAAA,G,QACClB,KAAKwE,UACJxE,KAAKuE,OACHE,QAAS,WAA0C,QAA9B,EAAAzE,KAAKC,aAAc,kBAAW,QAAI,IACvDwE,QAAS,SAAsC,QAA5B,EAAAzE,KAAKC,aAAc,gBAAS,QAAI,GACvD,EC3BDyE,eAAeC,OAAQ,YAAahF,GACpC+E,eAAeC,OAAQ,mBAAoBpB,GAC3CmB,eAAeC,OAAQ,kBAAmBnB,GAC1CkB,eAAeC,OAAQ,kBAAmBlB,GAC1CiB,eAAeC,OAAQ,gBAAiBb,GACxCY,eAAeC,OAAQ,qBAAsBZ,GAC7CW,eAAeC,OAAQ,kBAAmBL,E","sources":["webpack://@travelopia/web-components/./src/slider/tp-slider.ts","webpack://@travelopia/web-components/./src/slider/tp-slider-slides.ts","webpack://@travelopia/web-components/./src/slider/tp-slider-slide.ts","webpack://@travelopia/web-components/./src/slider/tp-slider-arrow.ts","webpack://@travelopia/web-components/./src/slider/tp-slider-nav.ts","webpack://@travelopia/web-components/./src/slider/tp-slider-nav-item.ts","webpack://@travelopia/web-components/./src/slider/tp-slider-count.ts","webpack://@travelopia/web-components/./src/slider/index.ts"],"sourcesContent":["/**\n * Internal dependencies.\n */\nimport { TPSliderSlidesElement } from './tp-slider-slides';\nimport { TPSliderSlideElement } from './tp-slider-slide';\nimport { TPSliderCountElement } from './tp-slider-count';\nimport { TPSliderNavItemElement } from './tp-slider-nav-item';\nimport { TPSliderArrowElement } from './tp-slider-arrow';\n\n/**\n * TP Slider.\n */\nexport class TPSliderElement extends HTMLElement {\n\t/**\n\t * Properties.\n\t */\n\tprotected touchStartX: number = 0;\n\n\t/**\n\t * Constructor.\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\t// Set current slide.\n\t\tif ( ! this.getAttribute( 'current-slide' ) ) {\n\t\t\tthis.setAttribute( 'current-slide', '1' );\n\t\t}\n\n\t\t// Initialize slider.\n\t\tthis.slide();\n\t\tthis.setAttribute( 'initialized', 'yes' );\n\n\t\t// Event listeners.\n\t\twindow.addEventListener( 'resize', this.handleResize.bind( this ) );\n\t\tthis.addEventListener( 'touchstart', this.handleTouchStart.bind( this ) );\n\t\tthis.addEventListener( 'touchend', this.handleTouchEnd.bind( this ) );\n\t}\n\n\t/**\n\t * Get observed attributes.\n\t *\n\t * @return {Array} List of observed attributes.\n\t */\n\tstatic get observedAttributes(): string[] {\n\t\treturn [ 'current-slide', 'flexible-height', 'infinite' ];\n\t}\n\n\t/**\n\t * Attribute changed callback.\n\t *\n\t * @param {string} name Attribute name.\n\t * @param {string} oldValue Old value.\n\t * @param {string} newValue New value.\n\t */\n\tattributeChangedCallback( name: string = '', oldValue: string = '', newValue: string = '' ): void {\n\t\tif ( 'current-slide' === name && oldValue !== newValue ) {\n\t\t\tthis.slide();\n\t\t\tthis.dispatchEvent( new CustomEvent( 'slide-complete', { bubbles: true } ) );\n\t\t}\n\n\t\tthis.update();\n\t}\n\n\t/**\n\t * Get current slide index.\n\t *\n\t * @return {number} Current slide index.\n\t */\n\tget currentSlideIndex(): number {\n\t\treturn parseInt( this.getAttribute( 'current-slide' ) ?? '1' );\n\t}\n\n\t/**\n\t * Set current slide index.\n\t *\n\t * @param {number} index Slide index.\n\t */\n\tset currentSlideIndex( index: number ) {\n\t\tthis.setCurrentSlide( index );\n\t}\n\n\t/**\n\t * Get total number of slides.\n\t *\n\t * @return {number} Total slides.\n\t */\n\tgetTotalSlides(): number {\n\t\tconst slides: NodeListOf<TPSliderSlideElement> | null = this.querySelectorAll( 'tp-slider-slide' );\n\t\tif ( slides ) {\n\t\t\treturn slides.length;\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\t/**\n\t * Navigate to the next slide.\n\t */\n\tnext(): void {\n\t\tconst totalSlides: number = this.getTotalSlides();\n\n\t\tif ( this.currentSlideIndex >= totalSlides ) {\n\t\t\tif ( 'yes' === this.getAttribute( 'infinite' ) ) {\n\t\t\t\tthis.setCurrentSlide( 1 );\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.setCurrentSlide( this.currentSlideIndex + 1 );\n\t}\n\n\t/**\n\t * Navigate to the previous slide.\n\t */\n\tprevious(): void {\n\t\tif ( this.currentSlideIndex <= 1 ) {\n\t\t\tif ( 'yes' === this.getAttribute( 'infinite' ) ) {\n\t\t\t\tthis.setCurrentSlide( this.getTotalSlides() );\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.setCurrentSlide( this.currentSlideIndex - 1 );\n\t}\n\n\t/**\n\t * Get current slide index.\n\t *\n\t * @return {number} Current slide index.\n\t */\n\tgetCurrentSlide(): number {\n\t\treturn this.currentSlideIndex;\n\t}\n\n\t/**\n\t * Set the current slide index.\n\t *\n\t * @param {number} index Slide index.\n\t */\n\tsetCurrentSlide( index: number ): void {\n\t\tif ( index > this.getTotalSlides() || index <= 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.dispatchEvent( new CustomEvent( 'slide-set', { bubbles: true } ) );\n\t\tthis.setAttribute( 'current-slide', index.toString() );\n\t}\n\n\t/**\n\t * Slide to the current slide.\n\t *\n\t * @protected\n\t */\n\tprotected slide(): void {\n\t\t// Check if slider is disabled.\n\t\tif ( 'yes' === this.getAttribute( 'disabled' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get slides.\n\t\tconst slidesContainer: TPSliderSlidesElement | null = this.querySelector( 'tp-slider-slides' );\n\t\tconst slides: NodeListOf<TPSliderSlideElement> | null = this.querySelectorAll( 'tp-slider-slide' );\n\t\tif ( ! slidesContainer || ! slides ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// First, update the height.\n\t\tthis.updateHeight();\n\n\t\t// Now lets slide!\n\t\tslidesContainer.style.left = `-${ this.offsetWidth * ( this.currentSlideIndex - 1 ) }px`;\n\t}\n\n\t/**\n\t * Update stuff when any attribute has changed.\n\t * Example: Update subcomponents.\n\t */\n\tupdate(): void {\n\t\t// Get subcomponents.\n\t\tconst sliderNavItems: NodeListOf<TPSliderNavItemElement> | null = this.querySelectorAll( 'tp-slider-nav-item' );\n\t\tconst sliderCount: TPSliderCountElement | null = this.querySelector( 'tp-slider-count' );\n\t\tconst leftArrow: TPSliderArrowElement | null = this.querySelector( 'tp-slider-arrow[direction=\"previous\"]' );\n\t\tconst rightArrow: TPSliderArrowElement | null = this.querySelector( 'tp-slider-arrow[direction=\"next\"]' );\n\n\t\t// Set active slide.\n\t\tconst slides: NodeListOf<TPSliderSlideElement> | null = this.querySelectorAll( 'tp-slider-slide' );\n\t\tslides?.forEach( ( slide: TPSliderSlideElement, index: number ): void => {\n\t\t\tif ( this.currentSlideIndex - 1 === index ) {\n\t\t\t\tslide.setAttribute( 'active', 'yes' );\n\t\t\t} else {\n\t\t\t\tslide.removeAttribute( 'active' );\n\t\t\t}\n\t\t} );\n\n\t\t// Set current slider nav item.\n\t\tif ( sliderNavItems ) {\n\t\t\tsliderNavItems.forEach( ( navItem: TPSliderNavItemElement, index: number ): void => {\n\t\t\t\tif ( this.currentSlideIndex - 1 === index ) {\n\t\t\t\t\tnavItem.setAttribute( 'current', 'yes' );\n\t\t\t\t} else {\n\t\t\t\t\tnavItem.removeAttribute( 'current' );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Update slider count.\n\t\tif ( sliderCount ) {\n\t\t\tsliderCount.setAttribute( 'current', this.getCurrentSlide().toString() );\n\t\t\tsliderCount.setAttribute( 'total', this.getTotalSlides().toString() );\n\t\t}\n\n\t\t// Enable / disable arrows.\n\t\tif ( 'yes' !== this.getAttribute( 'infinite' ) ) {\n\t\t\tif ( this.getCurrentSlide() === this.getTotalSlides() ) {\n\t\t\t\trightArrow?.setAttribute( 'disabled', 'yes' );\n\t\t\t} else {\n\t\t\t\trightArrow?.removeAttribute( 'disabled' );\n\t\t\t}\n\n\t\t\tif ( 1 === this.getCurrentSlide() ) {\n\t\t\t\tleftArrow?.setAttribute( 'disabled', 'yes' );\n\t\t\t} else {\n\t\t\t\tleftArrow?.removeAttribute( 'disabled' );\n\t\t\t}\n\t\t} else {\n\t\t\trightArrow?.removeAttribute( 'disabled' );\n\t\t\tleftArrow?.removeAttribute( 'disabled' );\n\t\t}\n\t}\n\n\t/**\n\t * Update the height of the slider based on current slide.\n\t */\n\tupdateHeight(): void {\n\t\t// Get slides container to resize.\n\t\tconst slidesContainer: TPSliderSlidesElement | null = this.querySelector( 'tp-slider-slides' );\n\t\tif ( ! slidesContainer ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Bail early if we don't want it to be flexible height.\n\t\tif ( 'yes' !== this.getAttribute( 'flexible-height' ) ) {\n\t\t\t// Remove height property for good measure!\n\t\t\tslidesContainer.style.removeProperty( 'height' );\n\t\t\treturn;\n\t\t}\n\n\t\t// Get slides.\n\t\tconst slides: NodeListOf<TPSliderSlideElement> | null = this.querySelectorAll( 'tp-slider-slide' );\n\t\tif ( ! slides ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Set the height of the container to be the height of the current slide.\n\t\tconst height: number = slides[ this.currentSlideIndex - 1 ].scrollHeight;\n\t\tslidesContainer.style.height = `${ height }px`;\n\t}\n\n\t/**\n\t * Resize the slider when the window is resized.\n\t *\n\t * @protected\n\t */\n\tprotected handleResize(): void {\n\t\t// First, lets flag this component as resizing.\n\t\tthis.setAttribute( 'resizing', 'yes' );\n\n\t\t// Run the slide (so height can be resized).\n\t\tthis.slide();\n\n\t\t// Done, let's remove the flag.\n\t\t// We need to do this on a timeout to avoid a race condition with transitions.\n\t\tconst _this = this;\n\t\tsetTimeout( function() {\n\t\t\t_this.removeAttribute( 'resizing' );\n\t\t}, 10 );\n\t}\n\n\t/**\n\t * Detect touch start event, and store the starting location.\n\t *\n\t * @param {Event} e Touch event.\n\t *\n\t * @protected\n\t */\n\tprotected handleTouchStart( e: TouchEvent ): void {\n\t\tif ( 'yes' === this.getAttribute( 'swipe' ) ) {\n\t\t\tthis.touchStartX = e.touches[ 0 ].clientX;\n\t\t}\n\t}\n\n\t/**\n\t * Detect touch end event, and check if it was a left or right swipe.\n\t *\n\t * @param {Event} e Touch event.\n\t *\n\t * @protected\n\t */\n\tprotected handleTouchEnd( e: TouchEvent ): void {\n\t\tif ( 'yes' !== this.getAttribute( 'swipe' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst touchEndX: number = e.changedTouches[ 0 ].clientX;\n\t\tconst swipeDistance: number = touchEndX - this.touchStartX;\n\n\t\tif ( swipeDistance > 0 ) {\n\t\t\tthis.previous();\n\t\t} else if ( swipeDistance < 0 ) {\n\t\t\tthis.next();\n\t\t}\n\t}\n}\n","/**\n * TP Slider Slides.\n */\nexport class TPSliderSlidesElement extends HTMLElement {\n}\n","/**\n * TP Slider Slide.\n */\nexport class TPSliderSlideElement extends HTMLElement {\n}\n","/**\n * Internal dependencies.\n */\nimport { TPSliderElement } from './tp-slider';\n\n/**\n * TP Slider Arrow.\n */\nexport class TPSliderArrowElement extends HTMLElement {\n\t/**\n\t * Connected callback.\n\t */\n\tconnectedCallback(): void {\n\t\tthis.querySelector( 'button' )?.addEventListener( 'click', this.handleClick.bind( this ) );\n\t}\n\n\t/**\n\t * Handle when the button is clicked.\n\t */\n\thandleClick(): void {\n\t\tif ( 'yes' === this.getAttribute( 'disabled' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst slider: TPSliderElement | null = this.closest( 'tp-slider' );\n\t\tif ( ! slider ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( 'previous' === this.getAttribute( 'direction' ) ) {\n\t\t\tslider.previous();\n\t\t} else if ( 'next' === this.getAttribute( 'direction' ) ) {\n\t\t\tslider.next();\n\t\t}\n\t}\n}\n","/**\n * TP Slider Nav.\n */\nexport class TPSliderNavElement extends HTMLElement {\n}\n","/**\n * Internal dependencies.\n */\nimport { TPSliderElement } from './tp-slider';\nimport { TPSliderNavElement } from './tp-slider-nav';\n\n/**\n * TP Slider Nav Item.\n */\nexport class TPSliderNavItemElement extends HTMLElement {\n\t/**\n\t * Connected callback.\n\t */\n\tconnectedCallback(): void {\n\t\tthis.querySelector( 'button' )?.addEventListener( 'click', this.handleClick.bind( this ) );\n\t}\n\n\t/**\n\t * Handle when the button is clicked.\n\t */\n\thandleClick(): void {\n\t\tconst slider: TPSliderElement | null = this.closest( 'tp-slider' );\n\t\tif ( ! slider ) {\n\t\t\treturn;\n\t\t}\n\n\t\tslider.setCurrentSlide( this.getIndex() );\n\t}\n\n\t/**\n\t * Get index of this item inside the navigation.\n\t *\n\t * @return {number} Index.\n\t */\n\tgetIndex(): number {\n\t\tif ( this.getAttribute( 'index' ) ) {\n\t\t\treturn parseInt( this.getAttribute( 'index' ) ?? '0' );\n\t\t}\n\n\t\tconst slideNav: TPSliderNavElement | null = this.closest( 'tp-slider-nav' );\n\t\treturn Array.from( slideNav?.children ?? [] ).indexOf( this ) + 1;\n\t}\n}\n","/**\n * TP Slider Count.\n */\nexport class TPSliderCountElement extends HTMLElement {\n\t/**\n\t * Get observed attributes.\n\t *\n\t * @return {Array} Observed attributes.\n\t */\n\tstatic get observedAttributes(): string[] {\n\t\treturn [ 'current', 'total', 'format' ];\n\t}\n\n\t/**\n\t * Get format.\n\t *\n\t * @return {string} Format.\n\t */\n\tget format(): string {\n\t\treturn this.getAttribute( 'format' ) ?? '$current / $total';\n\t}\n\n\t/**\n\t * Set format.\n\t *\n\t * @param {string} format Format.\n\t */\n\tset format( format: string ) {\n\t\tthis.setAttribute( 'format', format );\n\t}\n\n\t/**\n\t * Attribute changed callback.\n\t */\n\tattributeChangedCallback(): void {\n\t\tthis.update();\n\t}\n\n\t/**\n\t * Update component.\n\t */\n\tupdate(): void {\n\t\tthis.innerHTML =\n\t\t\tthis.format\n\t\t\t\t.replace( '$current', this.getAttribute( 'current' ) ?? '' )\n\t\t\t\t.replace( '$total', this.getAttribute( 'total' ) ?? '' );\n\t}\n}\n","/**\n * Styles.\n */\nimport './style.scss';\n\n/**\n * Components.\n */\nimport { TPSliderElement } from './tp-slider';\nimport { TPSliderSlidesElement } from './tp-slider-slides';\nimport { TPSliderSlideElement } from './tp-slider-slide';\nimport { TPSliderArrowElement } from './tp-slider-arrow';\nimport { TPSliderNavElement } from './tp-slider-nav';\nimport { TPSliderNavItemElement } from './tp-slider-nav-item';\nimport { TPSliderCountElement } from './tp-slider-count';\n\n/**\n * Register Components.\n */\ncustomElements.define( 'tp-slider', TPSliderElement );\ncustomElements.define( 'tp-slider-slides', TPSliderSlidesElement );\ncustomElements.define( 'tp-slider-slide', TPSliderSlideElement );\ncustomElements.define( 'tp-slider-arrow', TPSliderArrowElement );\ncustomElements.define( 'tp-slider-nav', TPSliderNavElement );\ncustomElements.define( 'tp-slider-nav-item', TPSliderNavItemElement );\ncustomElements.define( 'tp-slider-count', TPSliderCountElement );\n"],"names":["TPSliderElement","HTMLElement","constructor","super","touchStartX","this","getAttribute","setAttribute","slide","window","addEventListener","handleResize","bind","handleTouchStart","handleTouchEnd","observedAttributes","attributeChangedCallback","name","oldValue","newValue","dispatchEvent","CustomEvent","bubbles","update","currentSlideIndex","parseInt","index","setCurrentSlide","getTotalSlides","slides","querySelectorAll","length","next","totalSlides","previous","getCurrentSlide","toString","slidesContainer","querySelector","updateHeight","style","left","offsetWidth","sliderNavItems","sliderCount","leftArrow","rightArrow","forEach","removeAttribute","navItem","removeProperty","height","scrollHeight","_this","setTimeout","e","touches","clientX","swipeDistance","changedTouches","TPSliderSlidesElement","TPSliderSlideElement","TPSliderArrowElement","connectedCallback","handleClick","slider","closest","TPSliderNavElement","TPSliderNavItemElement","getIndex","slideNav","Array","from","children","indexOf","TPSliderCountElement","format","innerHTML","replace","customElements","define"],"sourceRoot":""}
@@ -0,0 +1 @@
1
+ tp-slider{display:block}tp-slider-track{display:block;overflow-y:visible;overflow-x:clip;position:relative}tp-slider-slides{position:relative;display:flex;align-items:flex-start}tp-slider:not([resizing=yes]) tp-slider-slides{transition-duration:.6s;transition-timing-function:cubic-bezier(0.42, 0, 0.58, 1)}tp-slider-slide{flex:0 0 100%;scroll-snap-align:start}tp-slider[flexible-height=yes]:not([initialized]) tp-slider-slide:not(:first-child){display:none}tp-slider-nav{display:flex;gap:10px}
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@travelopia/web-components",
3
- "version": "0.0.8",
3
+ "version": "0.1.0",
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
- "exports": {
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
@@ -1,8 +0,0 @@
1
- export interface TPModalElement extends HTMLElement {
2
- open: Function;
3
- close: Function;
4
- }
5
-
6
- export interface TPModalCloseElement extends HTMLElement {
7
- closeModal: Function;
8
- }
@@ -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 |
@@ -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>
@@ -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 );
@@ -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
- }
@@ -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
- }