@travelopia/web-components 0.0.1 → 0.0.2

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.
@@ -0,0 +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)})();
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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://web-components/./src/modal/tp-modal.ts","webpack://web-components/./src/modal/tp-modal-close.ts","webpack://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":""}
@@ -0,0 +1 @@
1
+ tp-modal{display:none;background-color:rgba(0,0,0,.5);backdrop-filter:blur(2px);position:fixed;height:100%;width:100%;left:0;top:0;z-index:99;max-width:100%;overflow-y:auto;padding:20px;box-sizing:border-box}tp-modal[open]{display:flex}tp-modal-close{position:absolute;top:20px;right:20px}tp-modal-content{display:block;min-width:0;margin:auto;padding:20px;background-color:#fff;max-width:80ch}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travelopia/web-components",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Accessible web components for the modern web",
5
5
  "scripts": {
6
6
  "build": "webpack --config ./webpack.config.js --mode production --env=production",
package/.browserslistrc DELETED
@@ -1 +0,0 @@
1
- since 2019
package/.editorconfig DELETED
@@ -1,18 +0,0 @@
1
- # WordPress Coding Standards
2
- # https://make.wordpress.org/core/handbook/coding-standards/
3
-
4
- root = true
5
-
6
- [*]
7
- charset = utf-8
8
- end_of_line = lf
9
- insert_final_newline = true
10
- trim_trailing_whitespace = true
11
- indent_style = tab
12
-
13
- [{.jshintrc,*.json,*.yml,*.neon}]
14
- indent_style = space
15
- indent_size = 2
16
-
17
- [*.txt]
18
- end_of_line = crlf
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- node_modules
2
- dist
3
- vendor
package/.eslintrc.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "extends": [ "plugin:@wordpress/eslint-plugin/recommended-with-formatting" ],
3
- "overrides": [
4
- {
5
- "files": ["*.ts"],
6
- "rules": {
7
- "no-undef": "off",
8
- "no-unused-vars": "off",
9
- "import/no-unresolved": "off",
10
- "import/no-extraneous-dependencies": "off"
11
- }
12
- }
13
- ]
14
- }
package/.gitignore DELETED
@@ -1,24 +0,0 @@
1
- # --- Windows and Mac files
2
- [Tt]humbs.db
3
- .DS_Store
4
-
5
- # --- Packages
6
- node_modules
7
- vendor
8
-
9
- # --- Root
10
- /*
11
- !.browserslistrc
12
- !.editorconfig
13
- !.eslintignore
14
- !.eslintrc.json
15
- !.gitignore
16
- !LICENSE
17
- !package.json
18
- !package-lock.json
19
- !README.md
20
- !tsconfig.json
21
- !webpack.config.js
22
-
23
- # --- Components
24
- !src
@@ -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
- }
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "noImplicitAny": true,
5
- "noUnusedLocals": true,
6
- "noUnusedParameters": true,
7
- "strictNullChecks": true,
8
- "strictFunctionTypes": true,
9
- "strictBindCallApply": true,
10
- "strictPropertyInitialization": true,
11
- "noImplicitThis": true,
12
- "alwaysStrict": true,
13
- "noImplicitReturns": true,
14
- "module": "es6",
15
- "target": "es6",
16
- "jsx": "react-jsx",
17
- "allowJs": true,
18
- "moduleResolution": "node",
19
- "sourceMap": true,
20
- "allowSyntheticDefaultImports": true
21
- }
22
- }
package/webpack.config.js DELETED
@@ -1,88 +0,0 @@
1
- // External dependencies.
2
- const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
3
- const WebpackNotifierPlugin = require( 'webpack-notifier' );
4
- const TerserPlugin = require( 'terser-webpack-plugin' );
5
-
6
- // Config.
7
- module.exports = ( env ) => {
8
- // Build configuration.
9
- const buildConfig = {
10
- entry: {
11
- modal: './src/modal/index.ts',
12
- },
13
- module: {
14
- rules: [
15
- {
16
- test: /\.tsx?$/,
17
- use: 'ts-loader',
18
- exclude: /node_modules/,
19
- },
20
- {
21
- test: /\.(sa|sc|c)ss$/,
22
- use: [
23
- MiniCssExtractPlugin.loader,
24
- {
25
- loader: 'css-loader',
26
- options: {
27
- url: false,
28
- sourceMap: false,
29
- },
30
- },
31
- {
32
- loader: 'postcss-loader',
33
- },
34
- {
35
- loader: 'sass-loader',
36
- options: {
37
- sassOptions: {
38
- outputStyle: 'compressed',
39
- },
40
- },
41
- },
42
- ],
43
- },
44
- ],
45
- },
46
- resolve: {
47
- extensions: [ '*', '.js', '.ts', '.tsx' ],
48
- },
49
- output: {
50
- path: __dirname,
51
- filename: `dist/[name]/index.js`,
52
- publicPath: '/',
53
- },
54
- optimization: {
55
- removeEmptyChunks: true,
56
- minimize: true,
57
- minimizer: [ new TerserPlugin( {
58
- parallel: true,
59
- terserOptions: {
60
- format: {
61
- comments: false,
62
- },
63
- },
64
- extractComments: false,
65
- } ) ],
66
- },
67
- plugins: [
68
- new MiniCssExtractPlugin( {
69
- filename: `dist/[name]/style.css`,
70
- } ),
71
- ],
72
- performance: {
73
- hints: false,
74
- },
75
- devtool: 'source-map',
76
- };
77
-
78
- // Development environment.
79
- if ( 'development' in env ) {
80
- buildConfig.plugins.push( new WebpackNotifierPlugin( {
81
- title: 'Build',
82
- alwaysNotify: true,
83
- } ) );
84
- }
85
-
86
- // Return config.
87
- return [ buildConfig ];
88
- };