@progressive-development/pd-dialog 0.0.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/.editorconfig +29 -0
- package/.storybook/main.js +3 -0
- package/.storybook/server.mjs +8 -0
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/demo/index.html +29 -0
- package/index.js +1 -0
- package/package.json +69 -0
- package/pd-book-date-dialog.js +3 -0
- package/pd-popup-dialog.js +3 -0
- package/pd-popup.js +3 -0
- package/pd-submit-dialog.js +3 -0
- package/src/PdBookDatePopup.js +80 -0
- package/src/PdPopup.js +146 -0
- package/src/PdPopupDialog.js +205 -0
- package/src/PdSubmitDialog.js +225 -0
- package/stories/index.stories.js +44 -0
- package/test/pd-dialog.test.js +32 -0
- package/web-dev-server.config.mjs +27 -0
- package/web-test-runner.config.mjs +41 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# EditorConfig helps developers define and maintain consistent
|
|
2
|
+
# coding styles between different editors and IDEs
|
|
3
|
+
# editorconfig.org
|
|
4
|
+
|
|
5
|
+
root = true
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
[*]
|
|
9
|
+
|
|
10
|
+
# Change these settings to your own preference
|
|
11
|
+
indent_style = space
|
|
12
|
+
indent_size = 2
|
|
13
|
+
|
|
14
|
+
# We recommend you to keep these unchanged
|
|
15
|
+
end_of_line = lf
|
|
16
|
+
charset = utf-8
|
|
17
|
+
trim_trailing_whitespace = true
|
|
18
|
+
insert_final_newline = true
|
|
19
|
+
|
|
20
|
+
[*.md]
|
|
21
|
+
trim_trailing_whitespace = false
|
|
22
|
+
|
|
23
|
+
[*.json]
|
|
24
|
+
indent_size = 2
|
|
25
|
+
|
|
26
|
+
[*.{html,js,md}]
|
|
27
|
+
block_comment_start = /**
|
|
28
|
+
block_comment = *
|
|
29
|
+
block_comment_end = */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { storybookPlugin } from '@web/dev-server-storybook';
|
|
2
|
+
import baseConfig from '../web-dev-server.config.mjs';
|
|
3
|
+
|
|
4
|
+
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
5
|
+
...baseConfig,
|
|
6
|
+
open: '/',
|
|
7
|
+
plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
|
|
8
|
+
});
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 pd-dialog
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# \<pd-dialog>
|
|
2
|
+
|
|
3
|
+
This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i pd-dialog
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<script type="module">
|
|
15
|
+
import 'pd-dialog/pd-dialog.js';
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<pd-dialog></pd-dialog>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Linting and formatting
|
|
22
|
+
|
|
23
|
+
To scan the project for linting and formatting errors, run
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run lint
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To automatically fix linting and formatting errors, run
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run format
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Testing with Web Test Runner
|
|
36
|
+
|
|
37
|
+
To execute a single test run:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm run test
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
To run the tests in interactive watch mode run:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm run test:watch
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Demoing with Storybook
|
|
50
|
+
|
|
51
|
+
To run a local instance of Storybook for your component, run
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm run storybook
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
To build a production version of Storybook, run
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm run storybook:build
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## Tooling configs
|
|
65
|
+
|
|
66
|
+
For most of the tools, the configuration is in the `package.json` to minimize the amount of files in your project.
|
|
67
|
+
|
|
68
|
+
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
69
|
+
|
|
70
|
+
## Local Demo with `web-dev-server`
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npm start
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
To run a local development server that serves the basic demo located in `demo/index.html`
|
package/demo/index.html
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en-GB">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
background: #fafafa;
|
|
8
|
+
}
|
|
9
|
+
</style>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="demo"></div>
|
|
13
|
+
|
|
14
|
+
<script type="module">
|
|
15
|
+
import { html, render } from 'lit';
|
|
16
|
+
import '../pd-dialog.js';
|
|
17
|
+
|
|
18
|
+
const title = 'Hello owc World!';
|
|
19
|
+
render(
|
|
20
|
+
html`
|
|
21
|
+
<pd-dialog .title=${title}>
|
|
22
|
+
some light-dom
|
|
23
|
+
</pd-dialog>
|
|
24
|
+
`,
|
|
25
|
+
document.querySelector('#demo')
|
|
26
|
+
);
|
|
27
|
+
</script>
|
|
28
|
+
</body>
|
|
29
|
+
</html>
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PdDialog } from './src/PdDialog.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@progressive-development/pd-dialog",
|
|
3
|
+
"description": "Progressive Development dialog components.",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "PD Progressive Development",
|
|
6
|
+
"version": "0.0.1",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"module": "index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"analyze": "cem analyze --litelement",
|
|
11
|
+
"start": "web-dev-server",
|
|
12
|
+
"lint": "eslint --ext .js,.html . --ignore-path .gitignore && prettier \"**/*.js\" --check --ignore-path .gitignore",
|
|
13
|
+
"format": "eslint --ext .js,.html . --fix --ignore-path .gitignore && prettier \"**/*.js\" --write --ignore-path .gitignore",
|
|
14
|
+
"test": "web-test-runner --coverage",
|
|
15
|
+
"test:watch": "web-test-runner --watch",
|
|
16
|
+
"storybook": "npm run analyze -- --exclude dist && web-dev-server -c .storybook/server.mjs",
|
|
17
|
+
"storybook:build": "npm run analyze -- --exclude dist && build-storybook"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"lit": "^2.0.2",
|
|
21
|
+
"@progressive-development/pd-price": "0.0.2",
|
|
22
|
+
"@progressive-development/pd-forms": "0.0.11",
|
|
23
|
+
"@progressive-development/pd-icon": "0.0.2"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@custom-elements-manifest/analyzer": "^0.4.17",
|
|
27
|
+
"@open-wc/eslint-config": "^4.3.0",
|
|
28
|
+
"@open-wc/testing": "next",
|
|
29
|
+
"@web/dev-server": "^0.1.25",
|
|
30
|
+
"@web/dev-server-storybook": "next",
|
|
31
|
+
"@web/test-runner": "^0.13.20",
|
|
32
|
+
"eslint": "^7.32.0",
|
|
33
|
+
"eslint-config-prettier": "^8.3.0",
|
|
34
|
+
"husky": "^4.3.8",
|
|
35
|
+
"lint-staged": "^10.5.4",
|
|
36
|
+
"prettier": "^2.4.1"
|
|
37
|
+
},
|
|
38
|
+
"customElements": "custom-elements.json",
|
|
39
|
+
"eslintConfig": {
|
|
40
|
+
"extends": [
|
|
41
|
+
"@open-wc",
|
|
42
|
+
"prettier"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"prettier": {
|
|
46
|
+
"singleQuote": true,
|
|
47
|
+
"arrowParens": "avoid"
|
|
48
|
+
},
|
|
49
|
+
"husky": {
|
|
50
|
+
"hooks": {
|
|
51
|
+
"pre-commit": "lint-staged"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"lint-staged": {
|
|
55
|
+
"*.js": [
|
|
56
|
+
"eslint --fix",
|
|
57
|
+
"prettier --write"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"keywords": [
|
|
61
|
+
"pd",
|
|
62
|
+
"progressive",
|
|
63
|
+
"development",
|
|
64
|
+
"dialog",
|
|
65
|
+
"popup",
|
|
66
|
+
"submit",
|
|
67
|
+
"send"
|
|
68
|
+
]
|
|
69
|
+
}
|
package/pd-popup.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { LitElement, html, css } from 'lit';
|
|
7
|
+
|
|
8
|
+
import '@progressive-development/pd-price/pd-price.js';
|
|
9
|
+
import '../pd-popup-dialog.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* An example element.
|
|
13
|
+
*
|
|
14
|
+
* @slot - This element has a slot
|
|
15
|
+
* @csspart button - The button
|
|
16
|
+
*/
|
|
17
|
+
export class PdBookDatePopup extends LitElement {
|
|
18
|
+
/**
|
|
19
|
+
* @event date-approval - fired if date approved
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @event close-popup - fired if date canceled
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
static get styles() {
|
|
27
|
+
return css``;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static get properties() {
|
|
31
|
+
return {
|
|
32
|
+
date: { type: String },
|
|
33
|
+
price: { type: Number },
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
this.date = '';
|
|
40
|
+
this.price = 0;
|
|
41
|
+
this._buttons = [
|
|
42
|
+
{ name: 'Akkoord', key: 1 },
|
|
43
|
+
{ name: 'Cancel', key: 2 },
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
render() {
|
|
48
|
+
return html`
|
|
49
|
+
<pd-popup-dialog
|
|
50
|
+
class="popup-dialog"
|
|
51
|
+
title="Akkoord datum"
|
|
52
|
+
.buttons="${this._buttons}"
|
|
53
|
+
@button-clicked="${this._buttonClicked}"
|
|
54
|
+
>
|
|
55
|
+
<div slot="content">
|
|
56
|
+
<p><b>Datum van herstelling: </b>${this.date}</p>
|
|
57
|
+
<p>
|
|
58
|
+
Als uw woning ouder is dan 10 jaar, hebt U als particulier recht op
|
|
59
|
+
een verlaagd BTW-tarief van 6%, na het eenmalig invullen van een
|
|
60
|
+
BTW-attest. Anders geldt het normale tarief van 21%.
|
|
61
|
+
</p>
|
|
62
|
+
<pd-price
|
|
63
|
+
nettoPrice="${this.price}"
|
|
64
|
+
.taxArray="${[0.06, 0.21]}"
|
|
65
|
+
></pd-price>
|
|
66
|
+
</div>
|
|
67
|
+
</pd-popup-dialog>
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_buttonClicked(e) {
|
|
72
|
+
let eventName;
|
|
73
|
+
if (e.detail.button === '1') {
|
|
74
|
+
eventName = 'date-approval';
|
|
75
|
+
} else {
|
|
76
|
+
eventName = 'close-popup';
|
|
77
|
+
}
|
|
78
|
+
this.dispatchEvent(new CustomEvent(eventName));
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/PdPopup.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { LitElement, html, css } from 'lit';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* An example element.
|
|
10
|
+
*
|
|
11
|
+
* @slot - This element has a slot
|
|
12
|
+
* @csspart button - The button
|
|
13
|
+
*/
|
|
14
|
+
export class PdPopup extends LitElement {
|
|
15
|
+
static get styles() {
|
|
16
|
+
return css`
|
|
17
|
+
:host {
|
|
18
|
+
display: block;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
h1,
|
|
22
|
+
h2,
|
|
23
|
+
h3,
|
|
24
|
+
h4 {
|
|
25
|
+
color: var(--my-text-color, #084c61);
|
|
26
|
+
font-family: var(--my-font, Oswald);
|
|
27
|
+
/*
|
|
28
|
+
font-weight: bold;
|
|
29
|
+
font-size: 2em;
|
|
30
|
+
*/
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Popup box BEGIN */
|
|
34
|
+
/* The Modal (background) */
|
|
35
|
+
.modal {
|
|
36
|
+
display: none; /* Hidden by default */
|
|
37
|
+
position: fixed; /* Stay in place */
|
|
38
|
+
z-index: 100; /* Sit on top */
|
|
39
|
+
padding-top: 100px; /* Location of the box */
|
|
40
|
+
left: 0;
|
|
41
|
+
top: 0;
|
|
42
|
+
width: 100%; /* Full width */
|
|
43
|
+
height: 100%; /* Full height */
|
|
44
|
+
overflow: auto; /* Enable scroll if needed */
|
|
45
|
+
background-color: rgb(0, 0, 0); /* Fallback color */
|
|
46
|
+
background-color: rgba(0, 0, 0, 0.4); /* Black w/ opacity */
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Modal Content */
|
|
50
|
+
.modal-content {
|
|
51
|
+
background-color: #fefefe;
|
|
52
|
+
margin: auto;
|
|
53
|
+
padding: 20px;
|
|
54
|
+
padding-bottom: 130px;
|
|
55
|
+
border: 1px solid #888;
|
|
56
|
+
width: 80%;
|
|
57
|
+
max-width: 1200px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.modal-content-slot {
|
|
61
|
+
max-width: 1000px;
|
|
62
|
+
margin-left: 30px;
|
|
63
|
+
margin-right: 30px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* The Close Button */
|
|
67
|
+
.close {
|
|
68
|
+
color: #aaaaaa;
|
|
69
|
+
float: right;
|
|
70
|
+
font-size: 28px;
|
|
71
|
+
font-weight: bold;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.close:hover,
|
|
75
|
+
.close:focus {
|
|
76
|
+
color: #000;
|
|
77
|
+
text-decoration: none;
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
}
|
|
80
|
+
/* Popup box END */
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/*
|
|
85
|
+
static get properties() {
|
|
86
|
+
return {
|
|
87
|
+
// not needed at the moment
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
constructor() {
|
|
92
|
+
super();
|
|
93
|
+
// no need at the moment
|
|
94
|
+
}
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
render() {
|
|
98
|
+
return html`
|
|
99
|
+
<!-- Trigger/Open The Modal -->
|
|
100
|
+
<span @click="${this._activatePopup}" @keypress="${this._activatePopup}"
|
|
101
|
+
><slot name="small-view"></slot
|
|
102
|
+
></span>
|
|
103
|
+
|
|
104
|
+
<!-- The Modal -->
|
|
105
|
+
<div id="modalId" class="modal">
|
|
106
|
+
<!-- Modal content -->
|
|
107
|
+
<div class="modal-content">
|
|
108
|
+
<span
|
|
109
|
+
class="close"
|
|
110
|
+
@click="${this._closePopup}"
|
|
111
|
+
@keypress="${this._closePopup}"
|
|
112
|
+
>×</span
|
|
113
|
+
>
|
|
114
|
+
<div class="modal-content-slot">
|
|
115
|
+
<slot name="content"></slot>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
showPopup() {
|
|
123
|
+
this._activatePopup();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_activatePopup() {
|
|
127
|
+
// $('.hover_bkgr_fricc').show();
|
|
128
|
+
const modal = this.shadowRoot.getElementById('modalId');
|
|
129
|
+
modal.style.display = 'block';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
_closePopup() {
|
|
133
|
+
// $('.hover_bkgr_fricc').hide();
|
|
134
|
+
const modal = this.shadowRoot.getElementById('modalId');
|
|
135
|
+
modal.style.display = 'none';
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/*
|
|
139
|
+
// When the user clicks anywhere outside of the modal, close it
|
|
140
|
+
window.onclick = function(event) {
|
|
141
|
+
if (event.target == modal) {
|
|
142
|
+
modal.style.display = "none";
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
*/
|
|
146
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { LitElement, html, css } from 'lit';
|
|
7
|
+
|
|
8
|
+
import '@progressive-development/pd-forms/PdButton.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* An example element.
|
|
12
|
+
*
|
|
13
|
+
* @slot - This element has a slot
|
|
14
|
+
* @csspart button - The button
|
|
15
|
+
*/
|
|
16
|
+
export class PdPopupDialog extends LitElement {
|
|
17
|
+
/**
|
|
18
|
+
* @event button-clicked - fired if one of the configured buttons was clicked.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
static get styles() {
|
|
22
|
+
return css`
|
|
23
|
+
:host {
|
|
24
|
+
display: block;
|
|
25
|
+
|
|
26
|
+
--my-max-width: var(--popup-max-width, 600px);
|
|
27
|
+
--my-header-color: var(--popup-header-col, #084c61);
|
|
28
|
+
--my-content-color: var(--popup-content-col, #fefefe);
|
|
29
|
+
--my-footer-color: var(--popup-footer-col, #177e89);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
h1,
|
|
33
|
+
h2,
|
|
34
|
+
h3,
|
|
35
|
+
h4 {
|
|
36
|
+
color: var(--my-text-color, #084c61);
|
|
37
|
+
font-family: var(--my-font, Oswald);
|
|
38
|
+
/*
|
|
39
|
+
font-weight: bold;
|
|
40
|
+
font-size: 2em;
|
|
41
|
+
*/
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Popup box BEGIN */
|
|
45
|
+
/* The Modal (background) */
|
|
46
|
+
.modal {
|
|
47
|
+
display: block; /* Hidden by default */
|
|
48
|
+
position: fixed; /* Stay in place */
|
|
49
|
+
z-index: 100; /* Sit on top */
|
|
50
|
+
|
|
51
|
+
padding-top: 150px; /* Location of the box */
|
|
52
|
+
padding-left: 10px;
|
|
53
|
+
padding-right: 10px;
|
|
54
|
+
|
|
55
|
+
left: 0;
|
|
56
|
+
top: 0;
|
|
57
|
+
width: 100%; /* Full width */
|
|
58
|
+
height: 100%; /* Full height */
|
|
59
|
+
overflow: auto; /* Enable scroll if needed */
|
|
60
|
+
background-color: rgba(8, 76, 97, 0.1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Modal Content */
|
|
64
|
+
.modal-content {
|
|
65
|
+
background-color: #fefefe;
|
|
66
|
+
margin: auto;
|
|
67
|
+
border: 2px solid #666666;
|
|
68
|
+
box-shadow: -4px 4px 10px #1f2b2a;
|
|
69
|
+
max-width: var(--my-max-width);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.header {
|
|
73
|
+
background-color: var(--my-header-color);
|
|
74
|
+
height: 45px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.header-txt {
|
|
78
|
+
position: absolute;
|
|
79
|
+
padding-left: 15px;
|
|
80
|
+
padding-top: 4px;
|
|
81
|
+
font-family: Oswald;
|
|
82
|
+
font-size: 1.4em;
|
|
83
|
+
color: #fefefe;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.info-logo {
|
|
87
|
+
padding-top: 6px;
|
|
88
|
+
padding-left: 6px;
|
|
89
|
+
width: 2em;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.content {
|
|
93
|
+
padding: 10px;
|
|
94
|
+
background-color: var(--my-content-color);
|
|
95
|
+
height: 100%;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.footer {
|
|
99
|
+
display: flex;
|
|
100
|
+
background-color: var(--my-footer-color);
|
|
101
|
+
height: 50px;
|
|
102
|
+
justify-content: space-around;
|
|
103
|
+
padding-bottom: 15px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Popup box END */
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static get properties() {
|
|
111
|
+
return {
|
|
112
|
+
type: { type: String },
|
|
113
|
+
title: { type: String },
|
|
114
|
+
buttons: { type: Array },
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
constructor() {
|
|
119
|
+
super();
|
|
120
|
+
this.type = 'info';
|
|
121
|
+
this.title = 'Popup Title';
|
|
122
|
+
this.buttons = [];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
render() {
|
|
126
|
+
return html`
|
|
127
|
+
<!-- The Modal -->
|
|
128
|
+
<div id="modalId" class="modal">
|
|
129
|
+
<!-- Modal content -->
|
|
130
|
+
<div class="modal-content">
|
|
131
|
+
<div class="header">
|
|
132
|
+
<img
|
|
133
|
+
src="/images/${this._getImageNameForType()}.svg"
|
|
134
|
+
class="info-logo"
|
|
135
|
+
alt=""
|
|
136
|
+
/>
|
|
137
|
+
<span class="header-txt">${this.title}</span>
|
|
138
|
+
</div>
|
|
139
|
+
<div class="content">
|
|
140
|
+
<slot name="content"></slot>
|
|
141
|
+
</div>
|
|
142
|
+
<div class="footer">
|
|
143
|
+
${this.buttons.map(
|
|
144
|
+
bt => html`
|
|
145
|
+
<squi-button
|
|
146
|
+
data-key="${bt.key}"
|
|
147
|
+
@click="${this._handleButtonEvent}"
|
|
148
|
+
text="${bt.name}"
|
|
149
|
+
></squi-button>
|
|
150
|
+
`
|
|
151
|
+
)}
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
_handleButtonEvent(e) {
|
|
159
|
+
this.dispatchEvent(
|
|
160
|
+
new CustomEvent('button-clicked', {
|
|
161
|
+
detail: {
|
|
162
|
+
button: e.target.dataset.key,
|
|
163
|
+
},
|
|
164
|
+
})
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_getImageNameForType() {
|
|
169
|
+
switch (this.type) {
|
|
170
|
+
case 'info':
|
|
171
|
+
return 'information';
|
|
172
|
+
case 'warn':
|
|
173
|
+
return 'warning';
|
|
174
|
+
case 'error':
|
|
175
|
+
return 'error';
|
|
176
|
+
default:
|
|
177
|
+
return 'information';
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
showPopup() {
|
|
182
|
+
this._activatePopup();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
_activatePopup() {
|
|
186
|
+
// $('.hover_bkgr_fricc').show();
|
|
187
|
+
const modal = this.shadowRoot.getElementById('modalId');
|
|
188
|
+
modal.style.display = 'block';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
_closePopup() {
|
|
192
|
+
// $('.hover_bkgr_fricc').hide();
|
|
193
|
+
const modal = this.shadowRoot.getElementById('modalId');
|
|
194
|
+
modal.style.display = 'none';
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/*
|
|
198
|
+
// When the user clicks anywhere outside of the modal, close it
|
|
199
|
+
window.onclick = function(event) {
|
|
200
|
+
if (event.target == modal) {
|
|
201
|
+
modal.style.display = "none";
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
*/
|
|
205
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { LitElement, html, css } from 'lit';
|
|
7
|
+
|
|
8
|
+
import '@progressive-development/pd-icon';
|
|
9
|
+
import '../pd-popup-dialog.js';
|
|
10
|
+
|
|
11
|
+
export const STATUS_SEND = 1;
|
|
12
|
+
export const STATUS_SEND_SUCCESS = 2;
|
|
13
|
+
export const STATUS_SEND_FAILED = 3;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* An example element.
|
|
17
|
+
*
|
|
18
|
+
* @slot - This element has a slot
|
|
19
|
+
* @csspart button - The button
|
|
20
|
+
*/
|
|
21
|
+
export class PdSubmitDialog extends LitElement {
|
|
22
|
+
/**
|
|
23
|
+
* @event button-clicked - navigate to start page or close popup (failure case).
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
static get styles() {
|
|
27
|
+
return css`
|
|
28
|
+
:host {
|
|
29
|
+
display: block;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
h1,
|
|
33
|
+
h2,
|
|
34
|
+
h3,
|
|
35
|
+
h4 {
|
|
36
|
+
color: var(--my-text-color, #084c61);
|
|
37
|
+
font-family: var(--my-font, Oswald);
|
|
38
|
+
/*
|
|
39
|
+
font-weight: bold;
|
|
40
|
+
font-size: 2em;
|
|
41
|
+
*/
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.popup-dialog {
|
|
45
|
+
--popup-max-width: 1000px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.progress-container {
|
|
49
|
+
padding: 20px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.progress-row {
|
|
53
|
+
display: flex;
|
|
54
|
+
justify-content: start;
|
|
55
|
+
align-items: center;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.first-row-tmp {
|
|
59
|
+
width: 80px;
|
|
60
|
+
height: 40px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.loader {
|
|
64
|
+
border: 16px solid #f3f3f3; /* Light grey */
|
|
65
|
+
border-top: 16px solid #3498db; /* Blue */
|
|
66
|
+
border-radius: 50%;
|
|
67
|
+
width: 10px;
|
|
68
|
+
height: 10px;
|
|
69
|
+
animation: spin 2s linear infinite;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.success-icon {
|
|
73
|
+
padding-top: 5px;
|
|
74
|
+
--squi-icon-size: 2rem;
|
|
75
|
+
--squi-icon-fill-active: green;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.error-icon {
|
|
79
|
+
padding-top: 5px;
|
|
80
|
+
--squi-icon-size: 2rem;
|
|
81
|
+
--squi-icon-fill: darkred;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@keyframes spin {
|
|
85
|
+
0% {
|
|
86
|
+
transform: rotate(0deg);
|
|
87
|
+
}
|
|
88
|
+
100% {
|
|
89
|
+
transform: rotate(360deg);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static get properties() {
|
|
96
|
+
return {
|
|
97
|
+
title: { type: String },
|
|
98
|
+
type: { type: String }, // mail, order (default)
|
|
99
|
+
status: { type: Number },
|
|
100
|
+
statusMsg: { type: String },
|
|
101
|
+
confirmMail: { type: String },
|
|
102
|
+
_buttons: { type: Array },
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
constructor() {
|
|
107
|
+
super();
|
|
108
|
+
this.title = 'Order Submit Title';
|
|
109
|
+
this.type = 'order';
|
|
110
|
+
this.status = 0;
|
|
111
|
+
this.statusMsg = '';
|
|
112
|
+
this.confirmMail = '';
|
|
113
|
+
this._buttons = [];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
updated(changedProps) {
|
|
117
|
+
if (changedProps.has('status')) {
|
|
118
|
+
if (this.status === STATUS_SEND_SUCCESS) {
|
|
119
|
+
this._buttons = [
|
|
120
|
+
{
|
|
121
|
+
name:
|
|
122
|
+
this.type === 'mail'
|
|
123
|
+
? 'Close Popup'
|
|
124
|
+
: 'Terug naar de startpagina',
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
} else if (this.status === STATUS_SEND_FAILED) {
|
|
128
|
+
this._buttons = [];
|
|
129
|
+
if (this.type === 'mail') {
|
|
130
|
+
this._buttons = [{ name: 'Close Popup' }];
|
|
131
|
+
} else {
|
|
132
|
+
this._buttons = [
|
|
133
|
+
{ name: 'Bewerk gegevens', key: 2 },
|
|
134
|
+
{ name: 'Naar startpagina' },
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
this._buttons = [];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
render() {
|
|
144
|
+
return html`
|
|
145
|
+
<pd-popup-dialog
|
|
146
|
+
class="popup-dialog"
|
|
147
|
+
title="${this.title}"
|
|
148
|
+
.buttons="${this._buttons}"
|
|
149
|
+
@button-clicked="${this._goToStartpage}"
|
|
150
|
+
>
|
|
151
|
+
<div slot="content">
|
|
152
|
+
${this.type === 'mail'
|
|
153
|
+
? html`<p>
|
|
154
|
+
Bedankt voor uw e-mail. Deze wordt nu verzonden. Je ontvangt
|
|
155
|
+
reactie op uw mail per e-mail naar <em>${this.confirmMail}</em>.
|
|
156
|
+
</p>`
|
|
157
|
+
: html`<p>
|
|
158
|
+
Bedank voor uw bestelling. Momenteel verwerken we uw gegevens. U
|
|
159
|
+
zal een e-mail ontvangen met de bevestiging van uw bestelling.
|
|
160
|
+
Alvast bedankt voor het vertrouwen in Ticomi Technics als uw
|
|
161
|
+
servicepartner voor uw verwarming.
|
|
162
|
+
</p>`}
|
|
163
|
+
<div class="progress-container">
|
|
164
|
+
<div class="progress-row">${this._renderProgressRow()}</div>
|
|
165
|
+
</div>
|
|
166
|
+
<p>${this.statusMsg}</p>
|
|
167
|
+
</div>
|
|
168
|
+
</pd-popup-dialog>
|
|
169
|
+
`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
_renderProgressRow() {
|
|
173
|
+
let value;
|
|
174
|
+
switch (this.status) {
|
|
175
|
+
case STATUS_SEND:
|
|
176
|
+
value = html` <div class="first-row-tmp">
|
|
177
|
+
<div class="loader"></div>
|
|
178
|
+
</div>
|
|
179
|
+
<span
|
|
180
|
+
>${this.type === 'mail'
|
|
181
|
+
? 'E-mail versturen, even geduld...'
|
|
182
|
+
: 'Uw gegevens worden verzonden.'}</span
|
|
183
|
+
>`;
|
|
184
|
+
break;
|
|
185
|
+
case STATUS_SEND_SUCCESS:
|
|
186
|
+
value = html` <div class="first-row-tmp">
|
|
187
|
+
<squi-icon
|
|
188
|
+
class="success-icon"
|
|
189
|
+
icon="checkBox"
|
|
190
|
+
activeIcon
|
|
191
|
+
></squi-icon>
|
|
192
|
+
</div>
|
|
193
|
+
<span
|
|
194
|
+
>${this.type === 'mail'
|
|
195
|
+
? 'Mail is succesvol verzonden, we zullen spoedig reageren.'
|
|
196
|
+
: 'Uw bestelling is succesvol verwerkt. Bekijk de bevestigingsmail voor meer informatie.'}</span
|
|
197
|
+
>`;
|
|
198
|
+
break;
|
|
199
|
+
case STATUS_SEND_FAILED:
|
|
200
|
+
value = html` <div class="first-row-tmp">
|
|
201
|
+
<squi-icon class="error-icon" icon="checkBox"></squi-icon>
|
|
202
|
+
</div>
|
|
203
|
+
<span
|
|
204
|
+
>${this.type === 'mail'
|
|
205
|
+
? 'Sending the mail failed.'
|
|
206
|
+
: 'Er is een fout opgetreden bij het opmaken van uw bestelling.'}</span
|
|
207
|
+
>`;
|
|
208
|
+
break;
|
|
209
|
+
default:
|
|
210
|
+
console.warn('Unexpected value');
|
|
211
|
+
}
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
_goToStartpage() {
|
|
216
|
+
this.dispatchEvent(
|
|
217
|
+
new CustomEvent('button-clicked', {
|
|
218
|
+
detail: {
|
|
219
|
+
// TODO: Get index from event
|
|
220
|
+
button: this._buttons[0].key,
|
|
221
|
+
},
|
|
222
|
+
})
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import '../pd-dialog.js';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'PdDialog',
|
|
6
|
+
component: 'pd-dialog',
|
|
7
|
+
argTypes: {
|
|
8
|
+
title: { control: 'text' },
|
|
9
|
+
counter: { control: 'number' },
|
|
10
|
+
textColor: { control: 'color' },
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function Template({ title = 'Hello world', counter = 5, textColor, slot }) {
|
|
15
|
+
return html`
|
|
16
|
+
<pd-dialog
|
|
17
|
+
style="--pd-dialog-text-color: ${textColor || 'black'}"
|
|
18
|
+
.title=${title}
|
|
19
|
+
.counter=${counter}
|
|
20
|
+
>
|
|
21
|
+
${slot}
|
|
22
|
+
</pd-dialog>
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const Regular = Template.bind({});
|
|
27
|
+
|
|
28
|
+
export const CustomTitle = Template.bind({});
|
|
29
|
+
CustomTitle.args = {
|
|
30
|
+
title: 'My title',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const CustomCounter = Template.bind({});
|
|
34
|
+
CustomCounter.args = {
|
|
35
|
+
counter: 123456,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const SlottedContent = Template.bind({});
|
|
39
|
+
SlottedContent.args = {
|
|
40
|
+
slot: html`<p>Slotted content</p>`,
|
|
41
|
+
};
|
|
42
|
+
SlottedContent.argTypes = {
|
|
43
|
+
slot: { table: { disable: true } },
|
|
44
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { fixture, expect } from '@open-wc/testing';
|
|
3
|
+
|
|
4
|
+
import '../pd-dialog.js';
|
|
5
|
+
|
|
6
|
+
describe('PdDialog', () => {
|
|
7
|
+
it('has a default title "Hey there" and counter 5', async () => {
|
|
8
|
+
const el = await fixture(html`<pd-dialog></pd-dialog>`);
|
|
9
|
+
|
|
10
|
+
expect(el.title).to.equal('Hey there');
|
|
11
|
+
expect(el.counter).to.equal(5);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('increases the counter on button click', async () => {
|
|
15
|
+
const el = await fixture(html`<pd-dialog></pd-dialog>`);
|
|
16
|
+
el.shadowRoot.querySelector('button').click();
|
|
17
|
+
|
|
18
|
+
expect(el.counter).to.equal(6);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('can override the title via attribute', async () => {
|
|
22
|
+
const el = await fixture(html`<pd-dialog title="attribute title"></pd-dialog>`);
|
|
23
|
+
|
|
24
|
+
expect(el.title).to.equal('attribute title');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('passes the a11y audit', async () => {
|
|
28
|
+
const el = await fixture(html`<pd-dialog></pd-dialog>`);
|
|
29
|
+
|
|
30
|
+
await expect(el).shadowDom.to.be.accessible();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
|
|
2
|
+
|
|
3
|
+
/** Use Hot Module replacement by adding --hmr to the start command */
|
|
4
|
+
const hmr = process.argv.includes('--hmr');
|
|
5
|
+
|
|
6
|
+
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
7
|
+
open: '/demo/',
|
|
8
|
+
/** Use regular watch mode if HMR is not enabled. */
|
|
9
|
+
watch: !hmr,
|
|
10
|
+
/** Resolve bare module imports */
|
|
11
|
+
nodeResolve: {
|
|
12
|
+
exportConditions: ['browser', 'development'],
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
16
|
+
// esbuildTarget: 'auto'
|
|
17
|
+
|
|
18
|
+
/** Set appIndex to enable SPA routing */
|
|
19
|
+
// appIndex: 'demo/index.html',
|
|
20
|
+
|
|
21
|
+
plugins: [
|
|
22
|
+
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
|
|
23
|
+
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
|
|
24
|
+
],
|
|
25
|
+
|
|
26
|
+
// See documentation for all available options
|
|
27
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// import { playwrightLauncher } from '@web/test-runner-playwright';
|
|
2
|
+
|
|
3
|
+
const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
|
|
4
|
+
|
|
5
|
+
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
6
|
+
/** Test files to run */
|
|
7
|
+
files: 'test/**/*.test.js',
|
|
8
|
+
|
|
9
|
+
/** Resolve bare module imports */
|
|
10
|
+
nodeResolve: {
|
|
11
|
+
exportConditions: ['browser', 'development'],
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
/** Filter out lit dev mode logs */
|
|
15
|
+
filterBrowserLogs(log) {
|
|
16
|
+
for (const arg of log.args) {
|
|
17
|
+
if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
25
|
+
// esbuildTarget: 'auto',
|
|
26
|
+
|
|
27
|
+
/** Amount of browsers to run concurrently */
|
|
28
|
+
// concurrentBrowsers: 2,
|
|
29
|
+
|
|
30
|
+
/** Amount of test files per browser to test concurrently */
|
|
31
|
+
// concurrency: 1,
|
|
32
|
+
|
|
33
|
+
/** Browsers to run tests on */
|
|
34
|
+
// browsers: [
|
|
35
|
+
// playwrightLauncher({ product: 'chromium' }),
|
|
36
|
+
// playwrightLauncher({ product: 'firefox' }),
|
|
37
|
+
// playwrightLauncher({ product: 'webkit' }),
|
|
38
|
+
// ],
|
|
39
|
+
|
|
40
|
+
// See documentation for all available options
|
|
41
|
+
});
|