@progressive-development/pd-wizard 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-wizard.js +3 -0
- package/src/PdSteps.js +306 -0
- package/src/PdWizard.js +292 -0
- package/stories/index.stories.js +44 -0
- package/test/pd-wizard.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-wizard
|
|
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-wizard>
|
|
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-wizard
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<script type="module">
|
|
15
|
+
import 'pd-wizard/pd-wizard.js';
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<pd-wizard></pd-wizard>
|
|
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-wizard.js';
|
|
17
|
+
|
|
18
|
+
const title = 'Hello owc World!';
|
|
19
|
+
render(
|
|
20
|
+
html`
|
|
21
|
+
<pd-wizard .title=${title}>
|
|
22
|
+
some light-dom
|
|
23
|
+
</pd-wizard>
|
|
24
|
+
`,
|
|
25
|
+
document.querySelector('#demo')
|
|
26
|
+
);
|
|
27
|
+
</script>
|
|
28
|
+
</body>
|
|
29
|
+
</html>
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PdWizard } from './src/PdWizard.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@progressive-development/pd-wizard",
|
|
3
|
+
"description": "Webcomponent pd-wizard following open-wc recommendations",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "PD Progressive Development",
|
|
6
|
+
"directories": {
|
|
7
|
+
"test": "test"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"pd",
|
|
11
|
+
"progressive",
|
|
12
|
+
"development",
|
|
13
|
+
"wizard",
|
|
14
|
+
"order",
|
|
15
|
+
"steps"
|
|
16
|
+
],
|
|
17
|
+
"version": "0.0.1",
|
|
18
|
+
"main": "index.js",
|
|
19
|
+
"module": "index.js",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"analyze": "cem analyze --litelement",
|
|
22
|
+
"start": "web-dev-server",
|
|
23
|
+
"lint": "eslint --ext .js,.html . --ignore-path .gitignore && prettier \"**/*.js\" --check --ignore-path .gitignore",
|
|
24
|
+
"format": "eslint --ext .js,.html . --fix --ignore-path .gitignore && prettier \"**/*.js\" --write --ignore-path .gitignore",
|
|
25
|
+
"test": "web-test-runner --coverage",
|
|
26
|
+
"test:watch": "web-test-runner --watch",
|
|
27
|
+
"storybook": "npm run analyze -- --exclude dist && web-dev-server -c .storybook/server.mjs",
|
|
28
|
+
"storybook:build": "npm run analyze -- --exclude dist && build-storybook"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"lit": "^2.0.2",
|
|
32
|
+
"@progressive-development/pd-forms": "0.0.11"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@custom-elements-manifest/analyzer": "^0.4.17",
|
|
36
|
+
"@open-wc/eslint-config": "^4.3.0",
|
|
37
|
+
"@open-wc/testing": "next",
|
|
38
|
+
"@web/dev-server": "^0.1.25",
|
|
39
|
+
"@web/dev-server-storybook": "next",
|
|
40
|
+
"@web/test-runner": "^0.13.20",
|
|
41
|
+
"eslint": "^7.32.0",
|
|
42
|
+
"eslint-config-prettier": "^8.3.0",
|
|
43
|
+
"husky": "^4.3.8",
|
|
44
|
+
"lint-staged": "^10.5.4",
|
|
45
|
+
"prettier": "^2.4.1"
|
|
46
|
+
},
|
|
47
|
+
"customElements": "custom-elements.json",
|
|
48
|
+
"eslintConfig": {
|
|
49
|
+
"extends": [
|
|
50
|
+
"@open-wc",
|
|
51
|
+
"prettier"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"prettier": {
|
|
55
|
+
"singleQuote": true,
|
|
56
|
+
"arrowParens": "avoid"
|
|
57
|
+
},
|
|
58
|
+
"husky": {
|
|
59
|
+
"hooks": {
|
|
60
|
+
"pre-commit": "lint-staged"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"lint-staged": {
|
|
64
|
+
"*.js": [
|
|
65
|
+
"eslint --fix",
|
|
66
|
+
"prettier --write"
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
package/pd-wizard.js
ADDED
package/src/PdSteps.js
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/* eslint-disable lit-a11y/click-events-have-key-events */
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
|
|
5
|
+
* This code may only be used under the BSD style license found at
|
|
6
|
+
* http://polymer.github.io/LICENSE.txt
|
|
7
|
+
* The complete set of authors may be found at
|
|
8
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
9
|
+
* The complete set of contributors may be found at
|
|
10
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
11
|
+
* Code distributed by Google as part of the polymer project is also
|
|
12
|
+
* subject to an additional IP rights grant found at
|
|
13
|
+
* http://polymer.github.io/PATENTS.txt
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import {LitElement, html, css} from 'lit';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* An example element.
|
|
20
|
+
*
|
|
21
|
+
* @slot - This element has a slot
|
|
22
|
+
* @csspart button - The button
|
|
23
|
+
*/
|
|
24
|
+
class PdSteps extends LitElement {
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fired when `step` (when not current) clicked.
|
|
28
|
+
* @event step-clicked
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
static get styles() {
|
|
32
|
+
return css`
|
|
33
|
+
:host {
|
|
34
|
+
|
|
35
|
+
--my-font: var(--app-font, Oswald);
|
|
36
|
+
--my-step-text-color: var(--squi-test, #177E89);
|
|
37
|
+
--my-step-current-text-color: var(--squi-test, #fefefe);
|
|
38
|
+
|
|
39
|
+
--my-step-current-name-circle-color: var(--squi-test, #FFC857);
|
|
40
|
+
--my-step-passed-name-circle-color: var(--squi-test, #fefefe);
|
|
41
|
+
--my-step-name-circle-color: var(--squi-test, #fefefe);
|
|
42
|
+
|
|
43
|
+
--my-step-unfinished-border-color: var(--squi-test, #fefefe);
|
|
44
|
+
--my-step-passed-border-color: var(--squi-test, #fefefe);
|
|
45
|
+
--my-step-current-border-color: var(--squi-test, #fefefe);
|
|
46
|
+
|
|
47
|
+
--my-step-unfinished-color: var(--squi-test, #fefefe);
|
|
48
|
+
--my-step-passed-color: var(--squi-test, #fefefe);
|
|
49
|
+
--my-step-passed-gradient-color: var(--squi-test, #084c61);
|
|
50
|
+
--my-step-current-color: var(--squi-test, #177E89);
|
|
51
|
+
--my-step-current-gradient-color: var(--squi-test, #f3d7a0);
|
|
52
|
+
|
|
53
|
+
--my-step-hover-color: var(--squi-test, #3ab6db);
|
|
54
|
+
|
|
55
|
+
--my-bg-color: var(--squi-step-bg-color, #177E89);
|
|
56
|
+
--my-hr-bg-color: var(--squi-hr-bg-color, #fefefe);
|
|
57
|
+
|
|
58
|
+
display: block;
|
|
59
|
+
background-color: var(--my-bg-color);
|
|
60
|
+
|
|
61
|
+
/* Hack => Wegen HR Linie wird das elemt 10 nach oben geschoben, sonst immer Abstand <hr> block display etc. => wie zu lösen? */
|
|
62
|
+
margin-top: -10px;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.parent {
|
|
67
|
+
display: flex;
|
|
68
|
+
/*
|
|
69
|
+
flex-direction: row; /* default *
|
|
70
|
+
flex-wrap: nowrap; /* default *
|
|
71
|
+
*/
|
|
72
|
+
/* short hand for above lines => default, not needed */
|
|
73
|
+
flex-flow: row nowrap;
|
|
74
|
+
align-items: center;
|
|
75
|
+
/*height: 50px; /* Or whatever */
|
|
76
|
+
padding-bottom: 10px;
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.parent.circle {
|
|
81
|
+
justify-content: space-around;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.parent.tab {
|
|
85
|
+
justify-content: start;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* Eingeführt, um den Text unter dem Circle zentral darzustellen => !Funktioniert nur für circle im Augenblick*/
|
|
89
|
+
.step-container {
|
|
90
|
+
display: flex;
|
|
91
|
+
flex-direction: column;
|
|
92
|
+
align-items: center;
|
|
93
|
+
|
|
94
|
+
text-align: center;
|
|
95
|
+
z-index: 51;
|
|
96
|
+
width: 100%;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.step {
|
|
100
|
+
/*margin: auto; /* Magic!/*/
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.step.circle {
|
|
105
|
+
width: 40px; /* Or whatever */
|
|
106
|
+
height: 40px; /* Or whatever */
|
|
107
|
+
border-radius: 50%;
|
|
108
|
+
|
|
109
|
+
border: solid 1px var(--my-step-unfinished-border-color);
|
|
110
|
+
box-shadow: 1px 1px grey;
|
|
111
|
+
/*background-image: linear-gradient(to right, var(--my-step-unfinished-color), lightgrey);*/
|
|
112
|
+
background-color: var(--my-step-unfinished-color);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.step.tab {
|
|
116
|
+
width: 100%;
|
|
117
|
+
max-width: 250px;
|
|
118
|
+
height: 40px;
|
|
119
|
+
border: solid 1px var(--my-step-unfinished-border-color);
|
|
120
|
+
box-shadow: 1px 1px grey;
|
|
121
|
+
background-image: linear-gradient(to right, var(--my-step-unfinished-color) , grey);
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.step.tab:hover:not(.current) {
|
|
126
|
+
border: solid 1px yellow;
|
|
127
|
+
background-image: linear-gradient(to right, var(--my-step-hover-color), grey);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.circle.passed {
|
|
131
|
+
/*background-image: linear-gradient(to right, var(--my-step-passed-color) , var(--my-step-passed-gradient-color)); */
|
|
132
|
+
background-color: var(--my-step-passed-color);
|
|
133
|
+
border: solid 2px var(--my-step-passed-border-color);
|
|
134
|
+
cursor: pointer;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.circle.passed:hover {
|
|
138
|
+
background-color: var(--my-step-current-name-circle-color);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.circle.current {
|
|
142
|
+
/*background-image: linear-gradient(to right, var(--my-step-current-color) , var(--my-step-current-gradient-color)); */
|
|
143
|
+
background-color: var(--my-step-current-color);
|
|
144
|
+
border: solid 2px var(--my-step-current-border-color);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.tab.current {
|
|
148
|
+
background-image: linear-gradient(to right, var(--my-step-current-color), grey);
|
|
149
|
+
box-shadow: 1px 1px grey;
|
|
150
|
+
border-color: var(--my-step-current-border-color);
|
|
151
|
+
cursor: auto;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.step-nr {
|
|
155
|
+
font-family: var(--my-font);
|
|
156
|
+
color: var(--my-step-text-color);
|
|
157
|
+
font-weight: bold;
|
|
158
|
+
font-size: 1.5em;
|
|
159
|
+
line-height: 37px;
|
|
160
|
+
pointer-events: none;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* Style Tab ohne Step Nr /*/
|
|
164
|
+
.tab .step-nr {
|
|
165
|
+
display: none;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.step-name {
|
|
169
|
+
color: var(--my-step-text-color);
|
|
170
|
+
font-family: var(--my-font);
|
|
171
|
+
font-size: 1em;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* Style Circle ohne Step Name => ToDo: Nur ab bestimmter Breite /*/
|
|
175
|
+
.circle .step-name {
|
|
176
|
+
white-space: nowrap;
|
|
177
|
+
color: var(--my-step-name-circle-color);
|
|
178
|
+
/* display: none; */
|
|
179
|
+
font-weight: bold;
|
|
180
|
+
padding-top: 8px;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.circle .step-name.passed {
|
|
184
|
+
color: var(--my-step-passed-name-circle-color);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.circle .step-name.current {
|
|
188
|
+
color: var(--my-step-current-name-circle-color);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.circle .step-nr.current {
|
|
192
|
+
color: var(--my-step-current-text-color);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/* used for circle style */
|
|
196
|
+
hr {
|
|
197
|
+
/*background: linear-gradient(to right, var(--my-step-passed-color) , var(--my-step-unfinished-color));*/
|
|
198
|
+
background-color: var(--my-hr-bg-color);
|
|
199
|
+
height: 3px;
|
|
200
|
+
position: relative;
|
|
201
|
+
top: 33px;
|
|
202
|
+
z-index: 50;
|
|
203
|
+
width: 100%;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* Size Elements for small width */
|
|
207
|
+
@media (max-width: 600px) {
|
|
208
|
+
.parent {
|
|
209
|
+
/*height: 30px; /* Or whatever */
|
|
210
|
+
}
|
|
211
|
+
.step.circle {
|
|
212
|
+
height: 30px; /* Or whatever */
|
|
213
|
+
width: 30px;
|
|
214
|
+
}
|
|
215
|
+
.step.tab {
|
|
216
|
+
height: 30px; /* Or whatever */
|
|
217
|
+
}
|
|
218
|
+
hr {
|
|
219
|
+
height: 2px;
|
|
220
|
+
top: 28px;
|
|
221
|
+
}
|
|
222
|
+
.step-nr {
|
|
223
|
+
font-size: 1.2em;
|
|
224
|
+
text-align: center;
|
|
225
|
+
line-height: 28px;
|
|
226
|
+
}
|
|
227
|
+
.step-name {
|
|
228
|
+
font-size: 0.9em;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.circle .step-name {
|
|
232
|
+
padding-top: 3px;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
static get properties() {
|
|
239
|
+
return {
|
|
240
|
+
/**
|
|
241
|
+
* The steps for this component
|
|
242
|
+
*/
|
|
243
|
+
steps: {type: Array},
|
|
244
|
+
currentStepNr: {type: Number},
|
|
245
|
+
styleTyp: {type: String}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
constructor() {
|
|
250
|
+
super();
|
|
251
|
+
this.steps = [];
|
|
252
|
+
this.currentStepNr = -99;
|
|
253
|
+
this.styleTyp = 'circle';
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
render() {
|
|
257
|
+
switch (this.styleTyp) {
|
|
258
|
+
// TODO: Noch das gleiche, ggf. später gebraucht...
|
|
259
|
+
case 'circle':
|
|
260
|
+
return this._renderCircle();
|
|
261
|
+
case 'tab':
|
|
262
|
+
return this._renderCircle();
|
|
263
|
+
default:
|
|
264
|
+
return '';
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
_renderCircle() {
|
|
269
|
+
return html`
|
|
270
|
+
${this.styleTyp === 'circle' ? html`<hr/>` : ''}
|
|
271
|
+
<div class="parent ${this.styleTyp}">
|
|
272
|
+
${this.steps.map((st, index) => {
|
|
273
|
+
let pClass = ''
|
|
274
|
+
if (this.currentStepNr > index) {
|
|
275
|
+
pClass = this.currentStepNr === (index + 1) ? 'current' : 'passed';
|
|
276
|
+
}
|
|
277
|
+
return html`
|
|
278
|
+
<div class="step-container">
|
|
279
|
+
<div class="step ${this.styleTyp} ${pClass}" data-step="${index + 1}" @click="${this._stepClicked}">
|
|
280
|
+
<span class="step-nr ${pClass}">${index + 1}</span>
|
|
281
|
+
</div>
|
|
282
|
+
<span class="step-name ${pClass}">${st.name}</span>
|
|
283
|
+
</div>
|
|
284
|
+
|
|
285
|
+
`})}
|
|
286
|
+
</div>
|
|
287
|
+
`;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
_stepClicked(e) {
|
|
291
|
+
const stepNr = e.target.dataset.step;
|
|
292
|
+
if (stepNr < this.currentStepNr) {
|
|
293
|
+
this.dispatchEvent(new CustomEvent('go-to', {
|
|
294
|
+
detail: {
|
|
295
|
+
step: stepNr
|
|
296
|
+
},
|
|
297
|
+
bubbles: true,
|
|
298
|
+
composed: true
|
|
299
|
+
}));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
window.customElements.define('pd-steps', PdSteps);
|
|
306
|
+
|
package/src/PdWizard.js
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
|
|
4
|
+
* This code may only be used under the BSD style license found at
|
|
5
|
+
* http://polymer.github.io/LICENSE.txt
|
|
6
|
+
* The complete set of authors may be found at
|
|
7
|
+
* http://polymer.github.io/AUTHORS.txt
|
|
8
|
+
* The complete set of contributors may be found at
|
|
9
|
+
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
10
|
+
* Code distributed by Google as part of the polymer project is also
|
|
11
|
+
* subject to an additional IP rights grant found at
|
|
12
|
+
* http://polymer.github.io/PATENTS.txt
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { LitElement, html, css } from 'lit';
|
|
16
|
+
|
|
17
|
+
import '@progressive-development/pd-forms/PdButton.js';
|
|
18
|
+
import './PdSteps.js';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* An example element.
|
|
22
|
+
*
|
|
23
|
+
* @slot - This element has a slot
|
|
24
|
+
* @csspart button - The button
|
|
25
|
+
*/
|
|
26
|
+
export class PdWizard extends LitElement {
|
|
27
|
+
/**
|
|
28
|
+
* Fired when next step clicked
|
|
29
|
+
* @event next-step
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Fired when previous step clicked
|
|
34
|
+
* @event previous-step
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Fired when wizard submited
|
|
39
|
+
* @event submit-wizard
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Fired when wizard submited
|
|
43
|
+
* @event close-wizard
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
static get styles() {
|
|
47
|
+
return css`
|
|
48
|
+
:host {
|
|
49
|
+
--my-font: var(--app-font, Oswald);
|
|
50
|
+
|
|
51
|
+
--my-header-background-color: var(--squi-test, #084c61);
|
|
52
|
+
--my-header-text-color: var(--squi-test, white);
|
|
53
|
+
|
|
54
|
+
--my-footer-background-color: var(--squi-test, #fefefe);
|
|
55
|
+
|
|
56
|
+
display: block;
|
|
57
|
+
/*min-height: 100%;*/
|
|
58
|
+
height: 100%;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Layout Grid for the Wizard Component
|
|
62
|
+
Wird hier für die "Text-Bildschirmgröße" verwendet, umstellen/gleichziehen => verschiedene Implementierungen, die Flex Variante (ticomi-web) scheint am schlankesten...
|
|
63
|
+
*/
|
|
64
|
+
.layout-container {
|
|
65
|
+
/*min-height: 100%;*/
|
|
66
|
+
height: 100%;
|
|
67
|
+
display: grid;
|
|
68
|
+
grid-template-columns: minmax(10px, auto) minmax(300px, 1000px) minmax(
|
|
69
|
+
5px,
|
|
70
|
+
auto
|
|
71
|
+
);
|
|
72
|
+
/*grid-template-rows: auto minmax(30em, 1fr) 4.166rem; /* ToDo wie 100% hoch????* für content, damit footer unten ist?*/
|
|
73
|
+
gap: 1px;
|
|
74
|
+
grid-template-areas:
|
|
75
|
+
'header header header'
|
|
76
|
+
'. content .'
|
|
77
|
+
'. footer .';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Grid Area positions for layout container above */
|
|
81
|
+
.wiz-header {
|
|
82
|
+
grid-area: header;
|
|
83
|
+
}
|
|
84
|
+
.wiz-content {
|
|
85
|
+
grid-area: content;
|
|
86
|
+
margin-top: 20px; /* ToDo: Steps sind verschoben, daher hier mehr*/
|
|
87
|
+
/*min-height: 100%;*/
|
|
88
|
+
height: 100%;
|
|
89
|
+
max-width: 1200px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.wiz-buttons {
|
|
93
|
+
grid-area: footer;
|
|
94
|
+
display: flex;
|
|
95
|
+
/*padding-left: 50px;
|
|
96
|
+
padding-right: 50px;*/
|
|
97
|
+
justify-content: space-between;
|
|
98
|
+
background-color: var(--my-footer-background-color);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.wiz-breadcrumbs {
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.wiz-title {
|
|
105
|
+
text-align: center;
|
|
106
|
+
background-color: var(--my-header-background-color);
|
|
107
|
+
height: 80px;
|
|
108
|
+
line-height: 80px;
|
|
109
|
+
padding-left: 80px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.title {
|
|
113
|
+
font-family: var(--my-font);
|
|
114
|
+
font-size: 1.8em;
|
|
115
|
+
font-weight: bolder;
|
|
116
|
+
color: var(--my-header-text-color);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.logo {
|
|
120
|
+
max-width: 8rem;
|
|
121
|
+
width: 8rem; /* wird sonst im Chrome nicht angezeigt*/
|
|
122
|
+
position: absolute;
|
|
123
|
+
left: 20px;
|
|
124
|
+
top: 10px;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* The Close Button */
|
|
128
|
+
.close {
|
|
129
|
+
position: absolute;
|
|
130
|
+
color: #fefefe;
|
|
131
|
+
font-size: 2.5em;
|
|
132
|
+
font-weight: bold;
|
|
133
|
+
line-height: 1em;
|
|
134
|
+
top: 5px;
|
|
135
|
+
right: 10px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.close:hover,
|
|
139
|
+
.close:focus {
|
|
140
|
+
color: rgb(247, 211, 8);
|
|
141
|
+
text-decoration: none;
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* Size Elements for small width */
|
|
146
|
+
@media (max-width: 550px) {
|
|
147
|
+
.wiz-title {
|
|
148
|
+
height: 60px;
|
|
149
|
+
line-height: 60px;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.wiz-breadcrumbs {
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.title {
|
|
156
|
+
font-size: 1.5em;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.logo {
|
|
160
|
+
max-width: 6rem;
|
|
161
|
+
width: 6rem; /* wird sonst im Chrome nicht angezeigt*/
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.close {
|
|
165
|
+
font-size: 1.5em;
|
|
166
|
+
right: 5px;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* Size Elements for small width */
|
|
171
|
+
@media (max-width: 380px) {
|
|
172
|
+
.wiz-title {
|
|
173
|
+
text-align: right;
|
|
174
|
+
padding-right: 20px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.title {
|
|
178
|
+
font-size: 1.2em;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
static get properties() {
|
|
185
|
+
return {
|
|
186
|
+
currentNumber: { type: Number },
|
|
187
|
+
wizardSteps: { Array },
|
|
188
|
+
logo: { type: Object }
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
constructor() {
|
|
193
|
+
super();
|
|
194
|
+
this.currentNumber = -99;
|
|
195
|
+
this.wizardSteps = [];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
render() {
|
|
199
|
+
if (this.wizardSteps && this.wizardSteps.length > 0) {
|
|
200
|
+
return html`
|
|
201
|
+
<div class="layout-container">
|
|
202
|
+
<div class="wiz-header">
|
|
203
|
+
<div class="wiz-title">
|
|
204
|
+
${this.logo ? this.log : ''}
|
|
205
|
+
<span class="title"
|
|
206
|
+
>${this.currentNumber >= 1 && this.wizardSteps
|
|
207
|
+
? this.wizardSteps[this.currentNumber - 1].title
|
|
208
|
+
: 'No-Title'}</span
|
|
209
|
+
>
|
|
210
|
+
<span
|
|
211
|
+
class="close"
|
|
212
|
+
@click="${this._closeWizard}"
|
|
213
|
+
@keypress="${this._closeWizard}"
|
|
214
|
+
>×</span
|
|
215
|
+
>
|
|
216
|
+
</div>
|
|
217
|
+
<div class="wiz-breadcrumbs">
|
|
218
|
+
<pd-steps
|
|
219
|
+
.steps="${this.wizardSteps}"
|
|
220
|
+
currentStepNr="${this.currentNumber}"
|
|
221
|
+
></pd-steps>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<div class="wiz-content">
|
|
226
|
+
<div style="${this.currentNumber === 1 ? '' : 'display:none'}">
|
|
227
|
+
<slot name="step-1"></slot>
|
|
228
|
+
</div>
|
|
229
|
+
<div style="${this.currentNumber === 2 ? '' : 'display:none'}">
|
|
230
|
+
<slot name="step-2"></slot>
|
|
231
|
+
</div>
|
|
232
|
+
<div style="${this.currentNumber === 3 ? '' : 'display:none'}">
|
|
233
|
+
<slot name="step-3"></slot>
|
|
234
|
+
</div>
|
|
235
|
+
<div style="${this.currentNumber === 4 ? '' : 'display:none'}">
|
|
236
|
+
<slot name="step-4"></slot>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
<div class="wiz-buttons">
|
|
241
|
+
${this.currentNumber >= 1 && this.wizardSteps
|
|
242
|
+
? html`
|
|
243
|
+
<squi-button
|
|
244
|
+
@click="${this._previousStep}"
|
|
245
|
+
text="Terug"
|
|
246
|
+
style="visibility: ${this.currentNumber === 1
|
|
247
|
+
? 'hidden'
|
|
248
|
+
: 'visible'};"
|
|
249
|
+
></squi-button>
|
|
250
|
+
${this.currentNumber !== this.wizardSteps.length &&
|
|
251
|
+
this.wizardSteps[this.currentNumber - 1].next !== false
|
|
252
|
+
? html`<squi-button
|
|
253
|
+
@click="${this._nextStep}"
|
|
254
|
+
text="Volgende"
|
|
255
|
+
></squi-button>`
|
|
256
|
+
: ''}
|
|
257
|
+
${this.currentNumber === this.wizardSteps.length
|
|
258
|
+
? html`<squi-button
|
|
259
|
+
primary
|
|
260
|
+
@click="${this._submit}"
|
|
261
|
+
text="Order"
|
|
262
|
+
></squi-button>`
|
|
263
|
+
: ''}
|
|
264
|
+
`
|
|
265
|
+
: ''}
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
`;
|
|
269
|
+
}
|
|
270
|
+
return '';
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
_previousStep() {
|
|
274
|
+
this.dispatchEvent(new CustomEvent('previous-step'));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
_nextStep() {
|
|
278
|
+
this.dispatchEvent(new CustomEvent('next-step'));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
_submit() {
|
|
282
|
+
this.dispatchEvent(new CustomEvent('submit-wizard'));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
_closeWizard() {
|
|
286
|
+
// eslint-disable-next-line no-restricted-globals
|
|
287
|
+
const r = confirm('Data will be lost, abort current order?');
|
|
288
|
+
if (r === true) {
|
|
289
|
+
this.dispatchEvent(new CustomEvent('close-wizard'));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import '../pd-wizard.js';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'PdWizard',
|
|
6
|
+
component: 'pd-wizard',
|
|
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-wizard
|
|
17
|
+
style="--pd-wizard-text-color: ${textColor || 'black'}"
|
|
18
|
+
.title=${title}
|
|
19
|
+
.counter=${counter}
|
|
20
|
+
>
|
|
21
|
+
${slot}
|
|
22
|
+
</pd-wizard>
|
|
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-wizard.js';
|
|
5
|
+
|
|
6
|
+
describe('PdWizard', () => {
|
|
7
|
+
it('has a default title "Hey there" and counter 5', async () => {
|
|
8
|
+
const el = await fixture(html`<pd-wizard></pd-wizard>`);
|
|
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-wizard></pd-wizard>`);
|
|
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-wizard title="attribute title"></pd-wizard>`);
|
|
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-wizard></pd-wizard>`);
|
|
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
|
+
});
|