@progressive-development/pd-forms 0.1.35 → 0.1.37
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/package.json +1 -1
- package/pd-hover-box.js +3 -0
- package/src/PdBaseUiInput.js +11 -2
- package/src/PdHoverBox.js +130 -0
- package/stories/range.stories.js +34 -1
package/package.json
CHANGED
package/pd-hover-box.js
ADDED
package/src/PdBaseUiInput.js
CHANGED
|
@@ -34,6 +34,8 @@ import { PdBaseUI } from './PdBaseUi.js';
|
|
|
34
34
|
|
|
35
35
|
import { SharedInputStyles } from './shared-input-styles.js';
|
|
36
36
|
|
|
37
|
+
import '../pd-hover-box.js';
|
|
38
|
+
|
|
37
39
|
/**
|
|
38
40
|
* Available input types.
|
|
39
41
|
* Each input elemt set it's own type during constructor call.
|
|
@@ -230,9 +232,16 @@ import { SharedInputStyles } from './shared-input-styles.js';
|
|
|
230
232
|
return html`
|
|
231
233
|
<div class="label-header">
|
|
232
234
|
<label for="${forParam}">${this.label}${this.required && this.label ? this.defaultRequiredChar : ''}${additionalValue ? html` - <b>${additionalValue}</b>` : ''}</label>
|
|
233
|
-
${this.helperTxt ? html
|
|
235
|
+
${this.helperTxt ? html`
|
|
236
|
+
|
|
237
|
+
<pd-hover-box>
|
|
238
|
+
<pd-icon slot="normal-view" icon="helpIcon" activeIcon></pd-icon>
|
|
239
|
+
<p slot="info-view">${this.helperTxt}</p>
|
|
240
|
+
</pd-hover-box>
|
|
241
|
+
|
|
242
|
+
` : ""}
|
|
234
243
|
</div>
|
|
235
244
|
`;
|
|
236
245
|
}
|
|
237
246
|
|
|
238
|
-
}
|
|
247
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* eslint-disable lit-a11y/click-events-have-key-events */
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Lit element container for pd input elements.
|
|
7
|
+
*
|
|
8
|
+
* Used to:
|
|
9
|
+
* - Automatically validation of form content
|
|
10
|
+
* - Success/NotReady information for form-container
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { html, css } from 'lit';
|
|
14
|
+
import { PdBaseUI } from './PdBaseUi.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* An example element.
|
|
18
|
+
*
|
|
19
|
+
* @slot - This element has a slot
|
|
20
|
+
* @csspart button - The button
|
|
21
|
+
*/
|
|
22
|
+
export class PdHoverBox extends PdBaseUI {
|
|
23
|
+
|
|
24
|
+
static get properties() {
|
|
25
|
+
return {
|
|
26
|
+
_visible: { type: Boolean, state: true},
|
|
27
|
+
_toBottom: { type: Boolean},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static get styles() {
|
|
32
|
+
return [
|
|
33
|
+
PdBaseUI.styles,
|
|
34
|
+
css`
|
|
35
|
+
|
|
36
|
+
:host {
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.hover-box {
|
|
41
|
+
position: relative;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.info-view {
|
|
45
|
+
position: absolute;
|
|
46
|
+
z-index: 100;
|
|
47
|
+
background-color: var(--pd-hover-box-bg-col, var(--pd-default-dark-col));
|
|
48
|
+
|
|
49
|
+
border: 1px solid var(--pd-hover-box-border-col, var(--pd-default-col));
|
|
50
|
+
|
|
51
|
+
text-align: center;
|
|
52
|
+
padding: 10px;
|
|
53
|
+
width: 240px;
|
|
54
|
+
|
|
55
|
+
color: var(--pd-hover-box-font-col, white);
|
|
56
|
+
font-size: var(--pd-hover-box-font-size, 0.8em);
|
|
57
|
+
|
|
58
|
+
transition: opacity 0.2s ease-in;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.visible {
|
|
62
|
+
visibility: visible;
|
|
63
|
+
opacity: 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.hidden {
|
|
67
|
+
visibility: hidden;
|
|
68
|
+
opacity: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.to-bottom {
|
|
72
|
+
right: -3px;
|
|
73
|
+
top: -3px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.to-top {
|
|
77
|
+
right: -3px;
|
|
78
|
+
bottom: -3px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@media (max-width: 640px) {
|
|
82
|
+
.info-view-visible {
|
|
83
|
+
width: 190px;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
`];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
render() {
|
|
91
|
+
|
|
92
|
+
return html`
|
|
93
|
+
<div class="hover-box">
|
|
94
|
+
|
|
95
|
+
<div @click="${this._activateInfo}">
|
|
96
|
+
<slot name="normal-view"></slot>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<div id="infoViewId" @click="${this._closeInfo}" class="info-view ${this._visible ? "visible" : "hidden"} ${this._toBottom ? "to-bottom" : "to-top"}">
|
|
100
|
+
<slot name="info-view"></slot>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
</div>
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// eslint-disable-next-line class-methods-use-this
|
|
108
|
+
_activateInfo(e) {
|
|
109
|
+
|
|
110
|
+
const modal = this.shadowRoot.getElementById('infoViewId');
|
|
111
|
+
const rect = modal.getBoundingClientRect();
|
|
112
|
+
|
|
113
|
+
this._toBottom = !((modal.offsetHeight + rect.top + 50) > window.innerHeight);
|
|
114
|
+
this._visible = true;
|
|
115
|
+
|
|
116
|
+
e.stopPropagation();
|
|
117
|
+
|
|
118
|
+
// Nachteil: Wird immer bei jedem Click nach erstmaligem aktvieren ausgeführt. Der Code unten
|
|
119
|
+
// aber nur bei KLick auf das Fenster, daher zunächst so belassen.
|
|
120
|
+
// Nachtrag: Allerdings geht es nicht für mehrere Hilfetexte gleichzeitig. Zunächst zurückgenommen.
|
|
121
|
+
/* window.onclick = () => {
|
|
122
|
+
modal.style.display = "none";
|
|
123
|
+
}; */
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_closeInfo() {
|
|
127
|
+
this._visible = false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
}
|
package/stories/range.stories.js
CHANGED
|
@@ -46,7 +46,40 @@ function Template() {
|
|
|
46
46
|
<pd-range id="range5060Id"
|
|
47
47
|
class="quarter4"
|
|
48
48
|
label="50er/60er"
|
|
49
|
-
helperTxt="
|
|
49
|
+
helperTxt="Absolut kurz."
|
|
50
|
+
required
|
|
51
|
+
max="4"
|
|
52
|
+
value="0"
|
|
53
|
+
.optionValueMapper="${OPTIONS_GENRE}">
|
|
54
|
+
</pd-range>
|
|
55
|
+
</pd-form-row>
|
|
56
|
+
<pd-form-row>
|
|
57
|
+
<pd-range id="range5060Id"
|
|
58
|
+
class="quarter4"
|
|
59
|
+
label="50er/60er"
|
|
60
|
+
helperTxt="Hier steht ein Hilfstext, mit etwas Text."
|
|
61
|
+
required
|
|
62
|
+
max="4"
|
|
63
|
+
value="0"
|
|
64
|
+
.optionValueMapper="${OPTIONS_GENRE}">
|
|
65
|
+
</pd-range>
|
|
66
|
+
</pd-form-row>
|
|
67
|
+
<pd-form-row>
|
|
68
|
+
<pd-range id="range5060Id"
|
|
69
|
+
class="quarter4"
|
|
70
|
+
label="50er/60er"
|
|
71
|
+
helperTxt="Hier steht ein Hilfstext, oder aber auch ein etwas längeres Element. Mit mehr als nur etwas Text. Man weiß es nicht genau."
|
|
72
|
+
required
|
|
73
|
+
max="4"
|
|
74
|
+
value="0"
|
|
75
|
+
.optionValueMapper="${OPTIONS_GENRE}">
|
|
76
|
+
</pd-range>
|
|
77
|
+
</pd-form-row>
|
|
78
|
+
<pd-form-row>
|
|
79
|
+
<pd-range id="range5060Id"
|
|
80
|
+
class="quarter4"
|
|
81
|
+
label="50er/60er"
|
|
82
|
+
helperTxt="Hier steht ein Hilfstext, oder aber auch ein etwas längeres Element. Mit mehr als nur etwas Text. Man weiß es nicht genau. Aber jetzt mal etwas länger. Man weiß ja nie was hier so alles geschrieben wird."
|
|
50
83
|
required
|
|
51
84
|
max="4"
|
|
52
85
|
value="0"
|