@internetarchive/modal-manager 2.0.3 → 2.0.4-alpha-webdev7960.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/.editorconfig +29 -29
- package/.eslintrc.js +14 -14
- package/.github/workflows/ci.yml +30 -30
- package/.github/workflows/gh-pages-main.yml +42 -42
- package/.github/workflows/pr-preview.yml +40 -40
- package/LICENSE +661 -661
- package/README.md +139 -139
- package/custom-elements.json +170 -170
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/src/assets/arrow-left-icon.d.ts +2 -2
- package/dist/src/assets/arrow-left-icon.js +14 -14
- package/dist/src/assets/arrow-left-icon.js.map +1 -1
- package/dist/src/assets/ia-logo-icon.d.ts +2 -2
- package/dist/src/assets/ia-logo-icon.js +29 -29
- package/dist/src/assets/ia-logo-icon.js.map +1 -1
- package/dist/src/modal-config.d.ts +104 -104
- package/dist/src/modal-config.js +24 -24
- package/dist/src/modal-config.js.map +1 -1
- package/dist/src/modal-manager-host-bridge-interface.d.ts +12 -12
- package/dist/src/modal-manager-host-bridge-interface.js +1 -1
- package/dist/src/modal-manager-host-bridge-interface.js.map +1 -1
- package/dist/src/modal-manager-host-bridge.d.ts +34 -34
- package/dist/src/modal-manager-host-bridge.js +62 -62
- package/dist/src/modal-manager-host-bridge.js.map +1 -1
- package/dist/src/modal-manager-interface.d.ts +27 -27
- package/dist/src/modal-manager-interface.js +1 -1
- package/dist/src/modal-manager-interface.js.map +1 -1
- package/dist/src/modal-manager-mode.d.ts +10 -10
- package/dist/src/modal-manager-mode.js +11 -11
- package/dist/src/modal-manager-mode.js.map +1 -1
- package/dist/src/modal-manager.d.ts +137 -127
- package/dist/src/modal-manager.js +247 -234
- package/dist/src/modal-manager.js.map +1 -1
- package/dist/src/modal-template.d.ts +41 -41
- package/dist/src/modal-template.js +335 -335
- package/dist/src/modal-template.js.map +1 -1
- package/dist/src/shoelace/active-elements.d.ts +15 -15
- package/dist/src/shoelace/active-elements.js +27 -27
- package/dist/src/shoelace/active-elements.js.map +1 -1
- package/dist/src/shoelace/modal.d.ts +24 -24
- package/dist/src/shoelace/modal.js +131 -131
- package/dist/src/shoelace/modal.js.map +1 -1
- package/dist/src/shoelace/tabbable.d.ts +9 -9
- package/dist/src/shoelace/tabbable.js +169 -169
- package/dist/src/shoelace/tabbable.js.map +1 -1
- package/dist/test/modal-config.test.d.ts +1 -1
- package/dist/test/modal-config.test.js +69 -69
- package/dist/test/modal-config.test.js.map +1 -1
- package/dist/test/modal-manager.test.d.ts +1 -1
- package/dist/test/modal-manager.test.js +274 -274
- package/dist/test/modal-manager.test.js.map +1 -1
- package/dist/test/modal-template.test.d.ts +1 -1
- package/dist/test/modal-template.test.js +178 -178
- package/dist/test/modal-template.test.js.map +1 -1
- package/dist/vite.config.d.ts +2 -2
- package/dist/vite.config.js +22 -22
- package/dist/vite.config.js.map +1 -1
- package/docs/assets/css/main.css +2678 -2678
- package/docs/classes/_src_modal_config_.modalconfig.html +429 -429
- package/docs/classes/_src_modal_manager_.modalmanager.html +7702 -7702
- package/docs/classes/_src_modal_manager_host_bridge_.modalmanagerhostbridge.html +409 -409
- package/docs/classes/_src_modal_template_.modaltemplate.html +7096 -7096
- package/docs/enums/_src_modal_manager_mode_.modalmanagermode.html +196 -196
- package/docs/globals.html +150 -150
- package/docs/index.html +252 -252
- package/docs/interfaces/_src_modal_manager_host_bridge_interface_.modalmanagerhostbridgeinterface.html +210 -210
- package/docs/interfaces/_src_modal_manager_interface_.modalmanagerinterface.html +7095 -7095
- package/docs/modules/_index_.html +208 -208
- package/docs/modules/_src_modal_config_.html +146 -146
- package/docs/modules/_src_modal_manager_.html +146 -146
- package/docs/modules/_src_modal_manager_host_bridge_.html +146 -146
- package/docs/modules/_src_modal_manager_host_bridge_interface_.html +146 -146
- package/docs/modules/_src_modal_manager_interface_.html +146 -146
- package/docs/modules/_src_modal_manager_mode_.html +146 -146
- package/docs/modules/_src_modal_template_.html +146 -146
- package/docs/modules/_test_modal_config_test_.html +106 -106
- package/docs/modules/_test_modal_manager_test_.html +106 -106
- package/docs/modules/_test_modal_template_test_.html +106 -106
- package/index.html +300 -300
- package/index.ts +7 -7
- package/karma.conf.js +24 -24
- package/package.json +85 -85
- package/renovate.json +7 -7
- package/src/assets/arrow-left-icon.ts +15 -15
- package/src/assets/ia-logo-icon.ts +30 -30
- package/src/modal-config.ts +133 -133
- package/src/modal-manager-host-bridge-interface.ts +13 -13
- package/src/modal-manager-host-bridge.ts +82 -82
- package/src/modal-manager-interface.ts +30 -30
- package/src/modal-manager-mode.ts +10 -10
- package/src/modal-manager.ts +303 -283
- package/src/modal-template.ts +343 -343
- package/src/shoelace/LICENSE.md +6 -6
- package/src/shoelace/active-elements.ts +33 -33
- package/src/shoelace/modal.ts +166 -166
- package/src/shoelace/tabbable.ts +223 -223
- package/test/modal-config.test.ts +77 -77
- package/test/modal-manager.test.ts +347 -347
- package/test/modal-template.test.ts +206 -206
- package/tsconfig.json +21 -21
- package/vite.config.ts +23 -23
package/src/modal-template.ts
CHANGED
|
@@ -1,343 +1,343 @@
|
|
|
1
|
-
import { LitElement, html, css, CSSResult, TemplateResult, nothing } from 'lit';
|
|
2
|
-
import { property, customElement } from 'lit/decorators.js';
|
|
3
|
-
|
|
4
|
-
import '@internetarchive/ia-activity-indicator';
|
|
5
|
-
import '@internetarchive/icon-close';
|
|
6
|
-
|
|
7
|
-
import { ModalConfig } from './modal-config';
|
|
8
|
-
import IALogoIcon from './assets/ia-logo-icon';
|
|
9
|
-
import arrowLeftIcon from './assets/arrow-left-icon';
|
|
10
|
-
|
|
11
|
-
@customElement('modal-template')
|
|
12
|
-
export class ModalTemplate extends LitElement {
|
|
13
|
-
/**
|
|
14
|
-
* The ModalConfig that displayed the template
|
|
15
|
-
*
|
|
16
|
-
* @type {ModalConfig}
|
|
17
|
-
* @memberof ModalTemplate
|
|
18
|
-
*/
|
|
19
|
-
@property({ type: Object }) config: ModalConfig = new ModalConfig();
|
|
20
|
-
|
|
21
|
-
/** @inheritdoc */
|
|
22
|
-
render(): TemplateResult {
|
|
23
|
-
return html`
|
|
24
|
-
<div class="modal-wrapper">
|
|
25
|
-
<div class="modal-container">
|
|
26
|
-
<header style="background-color: ${this.config.headerColor}">
|
|
27
|
-
${this.config.showLeftNavButton
|
|
28
|
-
? this.leftNavButtonTemplate
|
|
29
|
-
: nothing}
|
|
30
|
-
${this.config.showCloseButton ? this.closeButtonTemplate : ''}
|
|
31
|
-
${this.config.showHeaderLogo
|
|
32
|
-
? html`<div class="logo-icon">${IALogoIcon}</div>`
|
|
33
|
-
: nothing}
|
|
34
|
-
${this.config.title
|
|
35
|
-
? html`<h1 class="title">${this.config.title}</h1>`
|
|
36
|
-
: ''}
|
|
37
|
-
${this.config.subtitle
|
|
38
|
-
? html`<h2 class="subtitle">${this.config.subtitle}</h2>`
|
|
39
|
-
: ''}
|
|
40
|
-
</header>
|
|
41
|
-
<section
|
|
42
|
-
class="modal-body"
|
|
43
|
-
style="background-color: ${this.config.bodyColor}"
|
|
44
|
-
>
|
|
45
|
-
<div class="content">
|
|
46
|
-
<div
|
|
47
|
-
class="processing-logo ${this.config.showProcessingIndicator
|
|
48
|
-
? ''
|
|
49
|
-
: 'hidden'}"
|
|
50
|
-
>
|
|
51
|
-
<ia-activity-indicator
|
|
52
|
-
.mode=${this.config.processingImageMode}
|
|
53
|
-
></ia-activity-indicator>
|
|
54
|
-
</div>
|
|
55
|
-
${this.config.headline
|
|
56
|
-
? html` <h1 class="headline">${this.config.headline}</h1> `
|
|
57
|
-
: ''}
|
|
58
|
-
${this.config.message
|
|
59
|
-
? html` <p class="message">${this.config.message}</p> `
|
|
60
|
-
: ''}
|
|
61
|
-
|
|
62
|
-
<div class="slot-container">
|
|
63
|
-
<slot> </slot>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
</section>
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
`;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Dispatch the `closeButtonPressed` event to the consumer
|
|
74
|
-
*
|
|
75
|
-
* @private
|
|
76
|
-
* @memberof ModalTemplate
|
|
77
|
-
*/
|
|
78
|
-
private handleCloseButton(e: Event): void {
|
|
79
|
-
e.preventDefault();
|
|
80
|
-
if (
|
|
81
|
-
e.type === 'keydown' &&
|
|
82
|
-
(e as KeyboardEvent).key !== ' ' &&
|
|
83
|
-
(e as KeyboardEvent).key !== 'Enter'
|
|
84
|
-
) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const event = new Event('closeButtonPressed');
|
|
88
|
-
this.dispatchEvent(event);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Dispatch the `leftNavButtonPressed` event to the consumer
|
|
93
|
-
*
|
|
94
|
-
* @private
|
|
95
|
-
* @memberof ModalTemplate
|
|
96
|
-
*/
|
|
97
|
-
private handleLeftNavButtonPressed(e: Event): void {
|
|
98
|
-
e.preventDefault();
|
|
99
|
-
if (
|
|
100
|
-
e.type === 'keydown' &&
|
|
101
|
-
(e as KeyboardEvent).key !== ' ' &&
|
|
102
|
-
(e as KeyboardEvent).key !== 'Enter'
|
|
103
|
-
) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
const event = new Event('leftNavButtonPressed');
|
|
107
|
-
this.dispatchEvent(event);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* The close button template
|
|
112
|
-
*
|
|
113
|
-
* @readonly
|
|
114
|
-
* @private
|
|
115
|
-
* @type {TemplateResult}
|
|
116
|
-
* @memberof ModalTemplate
|
|
117
|
-
*/
|
|
118
|
-
private get closeButtonTemplate(): TemplateResult {
|
|
119
|
-
return html`
|
|
120
|
-
<button
|
|
121
|
-
type="button"
|
|
122
|
-
class="close-button"
|
|
123
|
-
@click=${this.handleCloseButton}
|
|
124
|
-
@keydown=${this.handleCloseButton}
|
|
125
|
-
>
|
|
126
|
-
<ia-icon-close></ia-icon-close>
|
|
127
|
-
</button>
|
|
128
|
-
`;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
private get leftNavButtonTemplate(): TemplateResult {
|
|
132
|
-
return html`<button
|
|
133
|
-
type="button"
|
|
134
|
-
class="back-button"
|
|
135
|
-
@click=${this.handleLeftNavButtonPressed}
|
|
136
|
-
@keydown=${this.handleLeftNavButtonPressed}
|
|
137
|
-
>
|
|
138
|
-
${arrowLeftIcon} ${this.config.leftNavButtonText ?? ''}
|
|
139
|
-
</button> `;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** @inheritdoc */
|
|
143
|
-
static get styles(): CSSResult {
|
|
144
|
-
const modalLogoSize = css`var(--modalLogoSize, 6.5rem)`;
|
|
145
|
-
|
|
146
|
-
const processingImageSize = css`var(--processingImageSize, 7.5rem)`;
|
|
147
|
-
|
|
148
|
-
const modalCornerRadius = css`var(--modalCornerRadius, 1rem)`;
|
|
149
|
-
const modalBorder = css`var(--modalBorder, 2px solid black)`;
|
|
150
|
-
// if the content of the modal is too big to fit on screen, this sets the bottom margin
|
|
151
|
-
// it's not exact, but a close estimation
|
|
152
|
-
const modalBottomMarginCss = css`var(--modalBottomMargin, 2.5rem)`;
|
|
153
|
-
const modalTopMarginCss = css`var(--modalTopMargin, 5rem)`;
|
|
154
|
-
const modalHeaderBottomPaddingCss = css`var(--modalHeaderBottomPadding, 0.5em)`;
|
|
155
|
-
|
|
156
|
-
const modalBottomPadding = css`var(--modalBottomPadding, 2rem)`;
|
|
157
|
-
const scrollOffset = css`var(--modalScrollOffset, 5px)`;
|
|
158
|
-
|
|
159
|
-
const titleFontSize = css`var(--modalTitleFontSize, 1.8rem)`;
|
|
160
|
-
const subtitleFontSize = css`var(--modalSubtitleFontSize, 1.4rem)`;
|
|
161
|
-
const headlineFontSize = css`var(--modalHeadlineFontSize, 1.6rem)`;
|
|
162
|
-
const messageFontSize = css`var(--modalMessageFontSize, 1.4rem)`;
|
|
163
|
-
|
|
164
|
-
const titleLineHeight = css`var(--modalTitleLineHeight, normal)`;
|
|
165
|
-
const subtitleLineHeight = css`var(--modalSubtitleLineHeight, normal)`;
|
|
166
|
-
const headlineLineHeight = css`var(--modalHeadlineLineHeight, normal)`;
|
|
167
|
-
const messageLineHeight = css`var(--modalMessageLineHeight, normal)`;
|
|
168
|
-
|
|
169
|
-
return css`
|
|
170
|
-
.processing-logo {
|
|
171
|
-
margin: auto;
|
|
172
|
-
width: ${processingImageSize};
|
|
173
|
-
height: ${processingImageSize};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
.processing-logo.hidden {
|
|
177
|
-
height: 1rem;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.processing-logo.hidden ia-activity-indicator {
|
|
181
|
-
display: none;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.modal-wrapper {
|
|
185
|
-
outline: none;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.modal-container {
|
|
189
|
-
border-radius: ${modalCornerRadius};
|
|
190
|
-
width: 100%;
|
|
191
|
-
margin-top: ${modalTopMarginCss};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
header {
|
|
195
|
-
position: relative;
|
|
196
|
-
background-color: #36a483;
|
|
197
|
-
color: white;
|
|
198
|
-
border-radius: calc(${modalCornerRadius}) calc(${modalCornerRadius}) 0 0;
|
|
199
|
-
border: ${modalBorder};
|
|
200
|
-
border-bottom: 0;
|
|
201
|
-
text-align: center;
|
|
202
|
-
padding-bottom: ${modalHeaderBottomPaddingCss};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.title {
|
|
206
|
-
margin: 0;
|
|
207
|
-
padding: 0;
|
|
208
|
-
font-size: ${titleFontSize};
|
|
209
|
-
font-weight: bold;
|
|
210
|
-
line-height: ${titleLineHeight};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
.subtitle {
|
|
214
|
-
margin: 0;
|
|
215
|
-
padding: 0;
|
|
216
|
-
font-weight: normal;
|
|
217
|
-
padding-top: 0;
|
|
218
|
-
font-size: ${subtitleFontSize};
|
|
219
|
-
line-height: ${subtitleLineHeight};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
.modal-body {
|
|
223
|
-
background-color: #fbfbfd;
|
|
224
|
-
border-radius: 0 0 calc(${modalCornerRadius}) calc(${modalCornerRadius});
|
|
225
|
-
border: ${modalBorder};
|
|
226
|
-
border-top: 0;
|
|
227
|
-
padding: 0 1rem calc(${modalBottomPadding} - ${scrollOffset}) 1rem;
|
|
228
|
-
color: #333;
|
|
229
|
-
margin-bottom: 2.5rem;
|
|
230
|
-
min-height: 5rem;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
.content {
|
|
234
|
-
overflow-y: auto;
|
|
235
|
-
max-height: calc(100vh - (16.5rem + ${modalBottomMarginCss}));
|
|
236
|
-
min-height: 5rem;
|
|
237
|
-
padding: 0 0 calc(${scrollOffset}) 0;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
.headline {
|
|
241
|
-
font-size: ${headlineFontSize};
|
|
242
|
-
font-weight: bold;
|
|
243
|
-
text-align: center;
|
|
244
|
-
line-height: ${headlineLineHeight};
|
|
245
|
-
margin: 0;
|
|
246
|
-
padding: 0;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.message {
|
|
250
|
-
margin: 1rem 0 0 0;
|
|
251
|
-
text-align: center;
|
|
252
|
-
font-size: ${messageFontSize};
|
|
253
|
-
line-height: ${messageLineHeight};
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
.logo-icon {
|
|
257
|
-
border-radius: 100%;
|
|
258
|
-
border: 3px solid #fff;
|
|
259
|
-
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),
|
|
260
|
-
0 2px 2px 0 rgba(0, 0, 0, 0.08);
|
|
261
|
-
width: ${modalLogoSize};
|
|
262
|
-
height: ${modalLogoSize};
|
|
263
|
-
margin: -2.9rem auto 0.5rem auto;
|
|
264
|
-
background-color: black;
|
|
265
|
-
display: flex;
|
|
266
|
-
justify-content: center;
|
|
267
|
-
align-items: center;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
.logo-icon svg {
|
|
271
|
-
width: calc(${modalLogoSize} * 0.65);
|
|
272
|
-
height: calc(${modalLogoSize} * 0.65);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
.logo-icon svg .fill-color {
|
|
276
|
-
fill: white;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
.logo-icon svg .stroke-color {
|
|
280
|
-
stroke: red;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
.close-button {
|
|
284
|
-
position: absolute;
|
|
285
|
-
right: 1.2rem;
|
|
286
|
-
top: 1.2rem;
|
|
287
|
-
width: 2rem;
|
|
288
|
-
height: 2rem;
|
|
289
|
-
border-radius: 100%;
|
|
290
|
-
border: 0;
|
|
291
|
-
padding: 0;
|
|
292
|
-
cursor: pointer;
|
|
293
|
-
background-color: white;
|
|
294
|
-
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),
|
|
295
|
-
0 4px 4px 0 rgba(0, 0, 0, 0.08);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
.back-button {
|
|
299
|
-
position: absolute;
|
|
300
|
-
left: 1.2rem;
|
|
301
|
-
top: 1.2rem;
|
|
302
|
-
height: 2rem;
|
|
303
|
-
background-color: transparent;
|
|
304
|
-
outline: none;
|
|
305
|
-
border: none;
|
|
306
|
-
padding: 0;
|
|
307
|
-
cursor: pointer;
|
|
308
|
-
color: white;
|
|
309
|
-
font-family: inherit;
|
|
310
|
-
display: flex;
|
|
311
|
-
flex-direction: row;
|
|
312
|
-
align-items: center;
|
|
313
|
-
gap: 0.5rem;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
.back-button svg {
|
|
317
|
-
height: 1.5rem;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
.sr-only {
|
|
321
|
-
position: absolute;
|
|
322
|
-
width: 1px;
|
|
323
|
-
height: 1px;
|
|
324
|
-
padding: 0;
|
|
325
|
-
margin: -1px;
|
|
326
|
-
overflow: hidden;
|
|
327
|
-
clip: rect(0, 0, 0, 0);
|
|
328
|
-
border: 0;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
slot::slotted(.sr-only) {
|
|
332
|
-
position: absolute;
|
|
333
|
-
width: 1px;
|
|
334
|
-
height: 1px;
|
|
335
|
-
padding: 0;
|
|
336
|
-
margin: -1px;
|
|
337
|
-
overflow: hidden;
|
|
338
|
-
clip: rect(0, 0, 0, 0);
|
|
339
|
-
border: 0;
|
|
340
|
-
}
|
|
341
|
-
`;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
1
|
+
import { LitElement, html, css, CSSResult, TemplateResult, nothing } from 'lit';
|
|
2
|
+
import { property, customElement } from 'lit/decorators.js';
|
|
3
|
+
|
|
4
|
+
import '@internetarchive/ia-activity-indicator';
|
|
5
|
+
import '@internetarchive/icon-close';
|
|
6
|
+
|
|
7
|
+
import { ModalConfig } from './modal-config';
|
|
8
|
+
import IALogoIcon from './assets/ia-logo-icon';
|
|
9
|
+
import arrowLeftIcon from './assets/arrow-left-icon';
|
|
10
|
+
|
|
11
|
+
@customElement('modal-template')
|
|
12
|
+
export class ModalTemplate extends LitElement {
|
|
13
|
+
/**
|
|
14
|
+
* The ModalConfig that displayed the template
|
|
15
|
+
*
|
|
16
|
+
* @type {ModalConfig}
|
|
17
|
+
* @memberof ModalTemplate
|
|
18
|
+
*/
|
|
19
|
+
@property({ type: Object }) config: ModalConfig = new ModalConfig();
|
|
20
|
+
|
|
21
|
+
/** @inheritdoc */
|
|
22
|
+
render(): TemplateResult {
|
|
23
|
+
return html`
|
|
24
|
+
<div class="modal-wrapper">
|
|
25
|
+
<div class="modal-container">
|
|
26
|
+
<header style="background-color: ${this.config.headerColor}">
|
|
27
|
+
${this.config.showLeftNavButton
|
|
28
|
+
? this.leftNavButtonTemplate
|
|
29
|
+
: nothing}
|
|
30
|
+
${this.config.showCloseButton ? this.closeButtonTemplate : ''}
|
|
31
|
+
${this.config.showHeaderLogo
|
|
32
|
+
? html`<div class="logo-icon">${IALogoIcon}</div>`
|
|
33
|
+
: nothing}
|
|
34
|
+
${this.config.title
|
|
35
|
+
? html`<h1 class="title">${this.config.title}</h1>`
|
|
36
|
+
: ''}
|
|
37
|
+
${this.config.subtitle
|
|
38
|
+
? html`<h2 class="subtitle">${this.config.subtitle}</h2>`
|
|
39
|
+
: ''}
|
|
40
|
+
</header>
|
|
41
|
+
<section
|
|
42
|
+
class="modal-body"
|
|
43
|
+
style="background-color: ${this.config.bodyColor}"
|
|
44
|
+
>
|
|
45
|
+
<div class="content">
|
|
46
|
+
<div
|
|
47
|
+
class="processing-logo ${this.config.showProcessingIndicator
|
|
48
|
+
? ''
|
|
49
|
+
: 'hidden'}"
|
|
50
|
+
>
|
|
51
|
+
<ia-activity-indicator
|
|
52
|
+
.mode=${this.config.processingImageMode}
|
|
53
|
+
></ia-activity-indicator>
|
|
54
|
+
</div>
|
|
55
|
+
${this.config.headline
|
|
56
|
+
? html` <h1 class="headline">${this.config.headline}</h1> `
|
|
57
|
+
: ''}
|
|
58
|
+
${this.config.message
|
|
59
|
+
? html` <p class="message">${this.config.message}</p> `
|
|
60
|
+
: ''}
|
|
61
|
+
|
|
62
|
+
<div class="slot-container">
|
|
63
|
+
<slot> </slot>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</section>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Dispatch the `closeButtonPressed` event to the consumer
|
|
74
|
+
*
|
|
75
|
+
* @private
|
|
76
|
+
* @memberof ModalTemplate
|
|
77
|
+
*/
|
|
78
|
+
private handleCloseButton(e: Event): void {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
if (
|
|
81
|
+
e.type === 'keydown' &&
|
|
82
|
+
(e as KeyboardEvent).key !== ' ' &&
|
|
83
|
+
(e as KeyboardEvent).key !== 'Enter'
|
|
84
|
+
) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const event = new Event('closeButtonPressed');
|
|
88
|
+
this.dispatchEvent(event);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Dispatch the `leftNavButtonPressed` event to the consumer
|
|
93
|
+
*
|
|
94
|
+
* @private
|
|
95
|
+
* @memberof ModalTemplate
|
|
96
|
+
*/
|
|
97
|
+
private handleLeftNavButtonPressed(e: Event): void {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
if (
|
|
100
|
+
e.type === 'keydown' &&
|
|
101
|
+
(e as KeyboardEvent).key !== ' ' &&
|
|
102
|
+
(e as KeyboardEvent).key !== 'Enter'
|
|
103
|
+
) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const event = new Event('leftNavButtonPressed');
|
|
107
|
+
this.dispatchEvent(event);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The close button template
|
|
112
|
+
*
|
|
113
|
+
* @readonly
|
|
114
|
+
* @private
|
|
115
|
+
* @type {TemplateResult}
|
|
116
|
+
* @memberof ModalTemplate
|
|
117
|
+
*/
|
|
118
|
+
private get closeButtonTemplate(): TemplateResult {
|
|
119
|
+
return html`
|
|
120
|
+
<button
|
|
121
|
+
type="button"
|
|
122
|
+
class="close-button"
|
|
123
|
+
@click=${this.handleCloseButton}
|
|
124
|
+
@keydown=${this.handleCloseButton}
|
|
125
|
+
>
|
|
126
|
+
<ia-icon-close></ia-icon-close>
|
|
127
|
+
</button>
|
|
128
|
+
`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private get leftNavButtonTemplate(): TemplateResult {
|
|
132
|
+
return html`<button
|
|
133
|
+
type="button"
|
|
134
|
+
class="back-button"
|
|
135
|
+
@click=${this.handleLeftNavButtonPressed}
|
|
136
|
+
@keydown=${this.handleLeftNavButtonPressed}
|
|
137
|
+
>
|
|
138
|
+
${arrowLeftIcon} ${this.config.leftNavButtonText ?? ''}
|
|
139
|
+
</button> `;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** @inheritdoc */
|
|
143
|
+
static get styles(): CSSResult {
|
|
144
|
+
const modalLogoSize = css`var(--modalLogoSize, 6.5rem)`;
|
|
145
|
+
|
|
146
|
+
const processingImageSize = css`var(--processingImageSize, 7.5rem)`;
|
|
147
|
+
|
|
148
|
+
const modalCornerRadius = css`var(--modalCornerRadius, 1rem)`;
|
|
149
|
+
const modalBorder = css`var(--modalBorder, 2px solid black)`;
|
|
150
|
+
// if the content of the modal is too big to fit on screen, this sets the bottom margin
|
|
151
|
+
// it's not exact, but a close estimation
|
|
152
|
+
const modalBottomMarginCss = css`var(--modalBottomMargin, 2.5rem)`;
|
|
153
|
+
const modalTopMarginCss = css`var(--modalTopMargin, 5rem)`;
|
|
154
|
+
const modalHeaderBottomPaddingCss = css`var(--modalHeaderBottomPadding, 0.5em)`;
|
|
155
|
+
|
|
156
|
+
const modalBottomPadding = css`var(--modalBottomPadding, 2rem)`;
|
|
157
|
+
const scrollOffset = css`var(--modalScrollOffset, 5px)`;
|
|
158
|
+
|
|
159
|
+
const titleFontSize = css`var(--modalTitleFontSize, 1.8rem)`;
|
|
160
|
+
const subtitleFontSize = css`var(--modalSubtitleFontSize, 1.4rem)`;
|
|
161
|
+
const headlineFontSize = css`var(--modalHeadlineFontSize, 1.6rem)`;
|
|
162
|
+
const messageFontSize = css`var(--modalMessageFontSize, 1.4rem)`;
|
|
163
|
+
|
|
164
|
+
const titleLineHeight = css`var(--modalTitleLineHeight, normal)`;
|
|
165
|
+
const subtitleLineHeight = css`var(--modalSubtitleLineHeight, normal)`;
|
|
166
|
+
const headlineLineHeight = css`var(--modalHeadlineLineHeight, normal)`;
|
|
167
|
+
const messageLineHeight = css`var(--modalMessageLineHeight, normal)`;
|
|
168
|
+
|
|
169
|
+
return css`
|
|
170
|
+
.processing-logo {
|
|
171
|
+
margin: auto;
|
|
172
|
+
width: ${processingImageSize};
|
|
173
|
+
height: ${processingImageSize};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.processing-logo.hidden {
|
|
177
|
+
height: 1rem;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.processing-logo.hidden ia-activity-indicator {
|
|
181
|
+
display: none;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.modal-wrapper {
|
|
185
|
+
outline: none;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.modal-container {
|
|
189
|
+
border-radius: ${modalCornerRadius};
|
|
190
|
+
width: 100%;
|
|
191
|
+
margin-top: ${modalTopMarginCss};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
header {
|
|
195
|
+
position: relative;
|
|
196
|
+
background-color: #36a483;
|
|
197
|
+
color: white;
|
|
198
|
+
border-radius: calc(${modalCornerRadius}) calc(${modalCornerRadius}) 0 0;
|
|
199
|
+
border: ${modalBorder};
|
|
200
|
+
border-bottom: 0;
|
|
201
|
+
text-align: center;
|
|
202
|
+
padding-bottom: ${modalHeaderBottomPaddingCss};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.title {
|
|
206
|
+
margin: 0;
|
|
207
|
+
padding: 0;
|
|
208
|
+
font-size: ${titleFontSize};
|
|
209
|
+
font-weight: bold;
|
|
210
|
+
line-height: ${titleLineHeight};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.subtitle {
|
|
214
|
+
margin: 0;
|
|
215
|
+
padding: 0;
|
|
216
|
+
font-weight: normal;
|
|
217
|
+
padding-top: 0;
|
|
218
|
+
font-size: ${subtitleFontSize};
|
|
219
|
+
line-height: ${subtitleLineHeight};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.modal-body {
|
|
223
|
+
background-color: #fbfbfd;
|
|
224
|
+
border-radius: 0 0 calc(${modalCornerRadius}) calc(${modalCornerRadius});
|
|
225
|
+
border: ${modalBorder};
|
|
226
|
+
border-top: 0;
|
|
227
|
+
padding: 0 1rem calc(${modalBottomPadding} - ${scrollOffset}) 1rem;
|
|
228
|
+
color: #333;
|
|
229
|
+
margin-bottom: 2.5rem;
|
|
230
|
+
min-height: 5rem;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.content {
|
|
234
|
+
overflow-y: auto;
|
|
235
|
+
max-height: calc(100vh - (16.5rem + ${modalBottomMarginCss}));
|
|
236
|
+
min-height: 5rem;
|
|
237
|
+
padding: 0 0 calc(${scrollOffset}) 0;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.headline {
|
|
241
|
+
font-size: ${headlineFontSize};
|
|
242
|
+
font-weight: bold;
|
|
243
|
+
text-align: center;
|
|
244
|
+
line-height: ${headlineLineHeight};
|
|
245
|
+
margin: 0;
|
|
246
|
+
padding: 0;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.message {
|
|
250
|
+
margin: 1rem 0 0 0;
|
|
251
|
+
text-align: center;
|
|
252
|
+
font-size: ${messageFontSize};
|
|
253
|
+
line-height: ${messageLineHeight};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.logo-icon {
|
|
257
|
+
border-radius: 100%;
|
|
258
|
+
border: 3px solid #fff;
|
|
259
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),
|
|
260
|
+
0 2px 2px 0 rgba(0, 0, 0, 0.08);
|
|
261
|
+
width: ${modalLogoSize};
|
|
262
|
+
height: ${modalLogoSize};
|
|
263
|
+
margin: -2.9rem auto 0.5rem auto;
|
|
264
|
+
background-color: black;
|
|
265
|
+
display: flex;
|
|
266
|
+
justify-content: center;
|
|
267
|
+
align-items: center;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.logo-icon svg {
|
|
271
|
+
width: calc(${modalLogoSize} * 0.65);
|
|
272
|
+
height: calc(${modalLogoSize} * 0.65);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.logo-icon svg .fill-color {
|
|
276
|
+
fill: white;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.logo-icon svg .stroke-color {
|
|
280
|
+
stroke: red;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.close-button {
|
|
284
|
+
position: absolute;
|
|
285
|
+
right: 1.2rem;
|
|
286
|
+
top: 1.2rem;
|
|
287
|
+
width: 2rem;
|
|
288
|
+
height: 2rem;
|
|
289
|
+
border-radius: 100%;
|
|
290
|
+
border: 0;
|
|
291
|
+
padding: 0;
|
|
292
|
+
cursor: pointer;
|
|
293
|
+
background-color: white;
|
|
294
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),
|
|
295
|
+
0 4px 4px 0 rgba(0, 0, 0, 0.08);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.back-button {
|
|
299
|
+
position: absolute;
|
|
300
|
+
left: 1.2rem;
|
|
301
|
+
top: 1.2rem;
|
|
302
|
+
height: 2rem;
|
|
303
|
+
background-color: transparent;
|
|
304
|
+
outline: none;
|
|
305
|
+
border: none;
|
|
306
|
+
padding: 0;
|
|
307
|
+
cursor: pointer;
|
|
308
|
+
color: white;
|
|
309
|
+
font-family: inherit;
|
|
310
|
+
display: flex;
|
|
311
|
+
flex-direction: row;
|
|
312
|
+
align-items: center;
|
|
313
|
+
gap: 0.5rem;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.back-button svg {
|
|
317
|
+
height: 1.5rem;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.sr-only {
|
|
321
|
+
position: absolute;
|
|
322
|
+
width: 1px;
|
|
323
|
+
height: 1px;
|
|
324
|
+
padding: 0;
|
|
325
|
+
margin: -1px;
|
|
326
|
+
overflow: hidden;
|
|
327
|
+
clip: rect(0, 0, 0, 0);
|
|
328
|
+
border: 0;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
slot::slotted(.sr-only) {
|
|
332
|
+
position: absolute;
|
|
333
|
+
width: 1px;
|
|
334
|
+
height: 1px;
|
|
335
|
+
padding: 0;
|
|
336
|
+
margin: -1px;
|
|
337
|
+
overflow: hidden;
|
|
338
|
+
clip: rect(0, 0, 0, 0);
|
|
339
|
+
border: 0;
|
|
340
|
+
}
|
|
341
|
+
`;
|
|
342
|
+
}
|
|
343
|
+
}
|