@internetarchive/modal-manager 0.2.8 → 0.2.9-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/.editorconfig +29 -29
  2. package/.eslintrc.js +14 -14
  3. package/.github/workflows/ci.yml +26 -26
  4. package/LICENSE +661 -661
  5. package/README.md +139 -139
  6. package/custom-elements.json +170 -170
  7. package/demo/index.html +278 -278
  8. package/dist/index.d.ts +7 -7
  9. package/dist/index.js +5 -5
  10. package/dist/index.js.map +1 -1
  11. package/dist/src/modal-config.d.ts +92 -92
  12. package/dist/src/modal-config.js +22 -22
  13. package/dist/src/modal-config.js.map +1 -1
  14. package/dist/src/modal-manager-host-bridge-interface.d.ts +12 -12
  15. package/dist/src/modal-manager-host-bridge-interface.js.map +1 -1
  16. package/dist/src/modal-manager-host-bridge.d.ts +34 -34
  17. package/dist/src/modal-manager-host-bridge.js +62 -62
  18. package/dist/src/modal-manager-host-bridge.js.map +1 -1
  19. package/dist/src/modal-manager-interface.d.ts +25 -25
  20. package/dist/src/modal-manager-interface.js.map +1 -1
  21. package/dist/src/modal-manager-mode.d.ts +10 -10
  22. package/dist/src/modal-manager-mode.js +11 -11
  23. package/dist/src/modal-manager-mode.js.map +1 -1
  24. package/dist/src/modal-manager.d.ts +108 -108
  25. package/dist/src/modal-manager.js +189 -189
  26. package/dist/src/modal-manager.js.map +1 -1
  27. package/dist/src/modal-template.d.ts +32 -32
  28. package/dist/src/modal-template.js +276 -276
  29. package/dist/src/modal-template.js.map +1 -1
  30. package/dist/test/modal-config.test.d.ts +1 -1
  31. package/dist/test/modal-config.test.js +61 -61
  32. package/dist/test/modal-config.test.js.map +1 -1
  33. package/dist/test/modal-manager.test.d.ts +1 -1
  34. package/dist/test/modal-manager.test.js +200 -200
  35. package/dist/test/modal-manager.test.js.map +1 -1
  36. package/dist/test/modal-template.test.d.ts +1 -1
  37. package/dist/test/modal-template.test.js +95 -95
  38. package/dist/test/modal-template.test.js.map +1 -1
  39. package/docs/assets/css/main.css +2678 -2678
  40. package/docs/classes/_src_modal_config_.modalconfig.html +429 -429
  41. package/docs/classes/_src_modal_manager_.modalmanager.html +7702 -7702
  42. package/docs/classes/_src_modal_manager_host_bridge_.modalmanagerhostbridge.html +409 -409
  43. package/docs/classes/_src_modal_template_.modaltemplate.html +7096 -7096
  44. package/docs/enums/_src_modal_manager_mode_.modalmanagermode.html +196 -196
  45. package/docs/globals.html +150 -150
  46. package/docs/index.html +252 -252
  47. package/docs/interfaces/_src_modal_manager_host_bridge_interface_.modalmanagerhostbridgeinterface.html +210 -210
  48. package/docs/interfaces/_src_modal_manager_interface_.modalmanagerinterface.html +7095 -7095
  49. package/docs/modules/_index_.html +208 -208
  50. package/docs/modules/_src_modal_config_.html +146 -146
  51. package/docs/modules/_src_modal_manager_.html +146 -146
  52. package/docs/modules/_src_modal_manager_host_bridge_.html +146 -146
  53. package/docs/modules/_src_modal_manager_host_bridge_interface_.html +146 -146
  54. package/docs/modules/_src_modal_manager_interface_.html +146 -146
  55. package/docs/modules/_src_modal_manager_mode_.html +146 -146
  56. package/docs/modules/_src_modal_template_.html +146 -146
  57. package/docs/modules/_test_modal_config_test_.html +106 -106
  58. package/docs/modules/_test_modal_manager_test_.html +106 -106
  59. package/docs/modules/_test_modal_template_test_.html +106 -106
  60. package/index.ts +7 -7
  61. package/karma.conf.js +24 -24
  62. package/package.json +82 -82
  63. package/src/modal-config.ts +117 -117
  64. package/src/modal-manager-host-bridge-interface.ts +13 -13
  65. package/src/modal-manager-host-bridge.ts +82 -82
  66. package/src/modal-manager-interface.ts +28 -28
  67. package/src/modal-manager-mode.ts +10 -10
  68. package/src/modal-manager.ts +228 -228
  69. package/src/modal-template.ts +279 -279
  70. package/test/modal-config.test.ts +69 -69
  71. package/test/modal-manager.test.ts +245 -245
  72. package/test/modal-template.test.ts +111 -111
  73. package/tsconfig.json +20 -20
@@ -1,279 +1,279 @@
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/ia-activity-indicator';
5
- import closeIcon from '@internetarchive/icon-close';
6
- import iaLogo from '@internetarchive/icon-ia-logo';
7
-
8
- import { ModalConfig } from './modal-config';
9
-
10
- @customElement('modal-template')
11
- export class ModalTemplate extends LitElement {
12
- /**
13
- * The ModalConfig that displayed the template
14
- *
15
- * @type {ModalConfig}
16
- * @memberof ModalTemplate
17
- */
18
- @property({ type: Object }) config: ModalConfig = new ModalConfig();
19
-
20
- /** @inheritdoc */
21
- render(): TemplateResult {
22
- return html`
23
- <div class="modal-wrapper">
24
- <div class="modal-container">
25
- <header style="background-color: ${this.config.headerColor}">
26
- ${this.config.showCloseButton ? this.closeButtonTemplate : ''}
27
- ${this.config.showHeaderLogo
28
- ? html`<div class="logo-icon">${iaLogo}</div>`
29
- : nothing}
30
- ${this.config.title
31
- ? html`<h1 class="title">${this.config.title}</h1>`
32
- : ''}
33
- ${this.config.subtitle
34
- ? html`<h2 class="subtitle">${this.config.subtitle}</h2>`
35
- : ''}
36
- </header>
37
- <section
38
- class="modal-body"
39
- style="background-color: ${this.config.bodyColor}"
40
- >
41
- <div class="content">
42
- <div
43
- class="processing-logo ${this.config.showProcessingIndicator
44
- ? ''
45
- : 'hidden'}"
46
- >
47
- <ia-activity-indicator
48
- .mode=${this.config.processingImageMode}
49
- ></ia-activity-indicator>
50
- </div>
51
- ${this.config.headline
52
- ? html` <h1 class="headline">${this.config.headline}</h1> `
53
- : ''}
54
- ${this.config.message
55
- ? html` <p class="message">${this.config.message}</p> `
56
- : ''}
57
-
58
- <div class="slot-container">
59
- <slot> </slot>
60
- </div>
61
- </div>
62
- </section>
63
- </div>
64
- </div>
65
- `;
66
- }
67
-
68
- /**
69
- * Dispatch the `closeButtonPressed` event to the consumer
70
- *
71
- * @private
72
- * @memberof ModalTemplate
73
- */
74
- private handleCloseButton(): void {
75
- const event = new Event('closeButtonPressed');
76
- this.dispatchEvent(event);
77
- }
78
-
79
- /**
80
- * The close button template
81
- *
82
- * @readonly
83
- * @private
84
- * @type {TemplateResult}
85
- * @memberof ModalTemplate
86
- */
87
- private get closeButtonTemplate(): TemplateResult {
88
- return html`
89
- <button
90
- type="button"
91
- class="close-button"
92
- tabindex="0"
93
- @click=${this.handleCloseButton}
94
- >
95
- ${closeIcon}
96
- </button>
97
- `;
98
- }
99
-
100
- /** @inheritdoc */
101
- static get styles(): CSSResult {
102
- const modalLogoSize = css`var(--modalLogoSize, 6.5rem)`;
103
-
104
- const processingImageSize = css`var(--processingImageSize, 7.5rem)`;
105
-
106
- const modalCornerRadius = css`var(--modalCornerRadius, 1rem)`;
107
- const modalBorder = css`var(--modalBorder, 2px solid black)`;
108
- // if the content of the modal is too big to fit on screen, this sets the bottom margin
109
- // it's not exact, but a close estimation
110
- const modalBottomMarginCss = css`var(--modalBottomMargin, 2.5rem)`;
111
- const modalTopMarginCss = css`var(--modalTopMargin, 5rem)`;
112
- const modalHeaderBottomPaddingCss = css`var(--modalHeaderBottomPadding, 0.5em)`;
113
-
114
- const modalBottomPadding = css`var(--modalBottomPadding, 2rem)`;
115
- const scrollOffset = css`var(--modalScrollOffset, 5px)`;
116
-
117
- const titleFontSize = css`var(--modalTitleFontSize, 1.8rem)`;
118
- const subtitleFontSize = css`var(--modalSubtitleFontSize, 1.4rem)`;
119
- const headlineFontSize = css`var(--modalHeadlineFontSize, 1.6rem)`;
120
- const messageFontSize = css`var(--modalMessageFontSize, 1.4rem)`;
121
-
122
- const titleLineHeight = css`var(--modalTitleLineHeight, normal)`;
123
- const subtitleLineHeight = css`var(--modalSubtitleLineHeight, normal)`;
124
- const headlineLineHeight = css`var(--modalHeadlineLineHeight, normal)`;
125
- const messageLineHeight = css`var(--modalMessageLineHeight, normal)`;
126
-
127
- return css`
128
- .processing-logo {
129
- margin: auto;
130
- width: ${processingImageSize};
131
- height: ${processingImageSize};
132
- }
133
-
134
- .processing-logo.hidden {
135
- height: 1rem;
136
- }
137
-
138
- .processing-logo.hidden ia-activity-indicator {
139
- display: none;
140
- }
141
-
142
- .modal-wrapper {
143
- outline: none;
144
- }
145
-
146
- .modal-container {
147
- border-radius: ${modalCornerRadius};
148
- width: 100%;
149
- margin-top: ${modalTopMarginCss};
150
- }
151
-
152
- header {
153
- position: relative;
154
- background-color: #36a483;
155
- color: white;
156
- border-radius: calc(${modalCornerRadius}) calc(${modalCornerRadius}) 0 0;
157
- border: ${modalBorder};
158
- border-bottom: 0;
159
- text-align: center;
160
- padding-bottom: ${modalHeaderBottomPaddingCss};
161
- }
162
-
163
- .title {
164
- margin: 0;
165
- padding: 0;
166
- font-size: ${titleFontSize};
167
- font-weight: bold;
168
- line-height: ${titleLineHeight};
169
- }
170
-
171
- .subtitle {
172
- margin: 0;
173
- padding: 0;
174
- font-weight: normal;
175
- padding-top: 0;
176
- font-size: ${subtitleFontSize};
177
- line-height: ${subtitleLineHeight};
178
- }
179
-
180
- .modal-body {
181
- background-color: #f5f5f7;
182
- border-radius: 0 0 calc(${modalCornerRadius}) calc(${modalCornerRadius});
183
- border: ${modalBorder};
184
- border-top: 0;
185
- padding: 0 1rem calc(${modalBottomPadding} - ${scrollOffset}) 1rem;
186
- color: #333;
187
- margin-bottom: 2.5rem;
188
- min-height: 5rem;
189
- }
190
-
191
- .content {
192
- overflow-y: auto;
193
- max-height: calc(100vh - (16.5rem + ${modalBottomMarginCss}));
194
- min-height: 5rem;
195
- padding: 0 0 calc(${scrollOffset}) 0;
196
- }
197
-
198
- .headline {
199
- font-size: ${headlineFontSize};
200
- font-weight: bold;
201
- text-align: center;
202
- line-height: ${headlineLineHeight};
203
- margin: 0;
204
- padding: 0;
205
- }
206
-
207
- .message {
208
- margin: 1rem 0 0 0;
209
- text-align: center;
210
- font-size: ${messageFontSize};
211
- line-height: ${messageLineHeight};
212
- }
213
-
214
- .logo-icon {
215
- border-radius: 100%;
216
- border: 3px solid #fff;
217
- box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),
218
- 0 2px 2px 0 rgba(0, 0, 0, 0.08);
219
- width: ${modalLogoSize};
220
- height: ${modalLogoSize};
221
- margin: -2.9rem auto 0.5rem auto;
222
- background-color: black;
223
- display: flex;
224
- justify-content: center;
225
- align-items: center;
226
- }
227
-
228
- .logo-icon svg {
229
- width: calc(${modalLogoSize} * 0.65);
230
- height: calc(${modalLogoSize} * 0.65);
231
- }
232
-
233
- .logo-icon svg .fill-color {
234
- fill: white;
235
- }
236
-
237
- .logo-icon svg .stroke-color {
238
- stroke: red;
239
- }
240
-
241
- .close-button {
242
- position: absolute;
243
- right: 1.2rem;
244
- top: 1.2rem;
245
- width: 2rem;
246
- height: 2rem;
247
- border-radius: 100%;
248
- border: 0;
249
- padding: 0;
250
- cursor: pointer;
251
- background-color: white;
252
- box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),
253
- 0 4px 4px 0 rgba(0, 0, 0, 0.08);
254
- }
255
-
256
- .sr-only {
257
- position: absolute;
258
- width: 1px;
259
- height: 1px;
260
- padding: 0;
261
- margin: -1px;
262
- overflow: hidden;
263
- clip: rect(0, 0, 0, 0);
264
- border: 0;
265
- }
266
-
267
- slot::slotted(.sr-only) {
268
- position: absolute;
269
- width: 1px;
270
- height: 1px;
271
- padding: 0;
272
- margin: -1px;
273
- overflow: hidden;
274
- clip: rect(0, 0, 0, 0);
275
- border: 0;
276
- }
277
- `;
278
- }
279
- }
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/ia-activity-indicator';
5
+ import closeIcon from '@internetarchive/icon-close';
6
+ import iaLogo from '@internetarchive/icon-ia-logo';
7
+
8
+ import { ModalConfig } from './modal-config';
9
+
10
+ @customElement('modal-template')
11
+ export class ModalTemplate extends LitElement {
12
+ /**
13
+ * The ModalConfig that displayed the template
14
+ *
15
+ * @type {ModalConfig}
16
+ * @memberof ModalTemplate
17
+ */
18
+ @property({ type: Object }) config: ModalConfig = new ModalConfig();
19
+
20
+ /** @inheritdoc */
21
+ render(): TemplateResult {
22
+ return html`
23
+ <div class="modal-wrapper">
24
+ <div class="modal-container">
25
+ <header style="background-color: ${this.config.headerColor}">
26
+ ${this.config.showCloseButton ? this.closeButtonTemplate : ''}
27
+ ${this.config.showHeaderLogo
28
+ ? html`<div class="logo-icon">${iaLogo}</div>`
29
+ : nothing}
30
+ ${this.config.title
31
+ ? html`<h1 class="title">${this.config.title}</h1>`
32
+ : ''}
33
+ ${this.config.subtitle
34
+ ? html`<h2 class="subtitle">${this.config.subtitle}</h2>`
35
+ : ''}
36
+ </header>
37
+ <section
38
+ class="modal-body"
39
+ style="background-color: ${this.config.bodyColor}"
40
+ >
41
+ <div class="content">
42
+ <div
43
+ class="processing-logo ${this.config.showProcessingIndicator
44
+ ? ''
45
+ : 'hidden'}"
46
+ >
47
+ <ia-activity-indicator
48
+ .mode=${this.config.processingImageMode}
49
+ ></ia-activity-indicator>
50
+ </div>
51
+ ${this.config.headline
52
+ ? html` <h1 class="headline">${this.config.headline}</h1> `
53
+ : ''}
54
+ ${this.config.message
55
+ ? html` <p class="message">${this.config.message}</p> `
56
+ : ''}
57
+
58
+ <div class="slot-container">
59
+ <slot> </slot>
60
+ </div>
61
+ </div>
62
+ </section>
63
+ </div>
64
+ </div>
65
+ `;
66
+ }
67
+
68
+ /**
69
+ * Dispatch the `closeButtonPressed` event to the consumer
70
+ *
71
+ * @private
72
+ * @memberof ModalTemplate
73
+ */
74
+ private handleCloseButton(): void {
75
+ const event = new Event('closeButtonPressed');
76
+ this.dispatchEvent(event);
77
+ }
78
+
79
+ /**
80
+ * The close button template
81
+ *
82
+ * @readonly
83
+ * @private
84
+ * @type {TemplateResult}
85
+ * @memberof ModalTemplate
86
+ */
87
+ private get closeButtonTemplate(): TemplateResult {
88
+ return html`
89
+ <button
90
+ type="button"
91
+ class="close-button"
92
+ tabindex="0"
93
+ @click=${this.handleCloseButton}
94
+ >
95
+ ${closeIcon}
96
+ </button>
97
+ `;
98
+ }
99
+
100
+ /** @inheritdoc */
101
+ static get styles(): CSSResult {
102
+ const modalLogoSize = css`var(--modalLogoSize, 6.5rem)`;
103
+
104
+ const processingImageSize = css`var(--processingImageSize, 7.5rem)`;
105
+
106
+ const modalCornerRadius = css`var(--modalCornerRadius, 1rem)`;
107
+ const modalBorder = css`var(--modalBorder, 2px solid black)`;
108
+ // if the content of the modal is too big to fit on screen, this sets the bottom margin
109
+ // it's not exact, but a close estimation
110
+ const modalBottomMarginCss = css`var(--modalBottomMargin, 2.5rem)`;
111
+ const modalTopMarginCss = css`var(--modalTopMargin, 5rem)`;
112
+ const modalHeaderBottomPaddingCss = css`var(--modalHeaderBottomPadding, 0.5em)`;
113
+
114
+ const modalBottomPadding = css`var(--modalBottomPadding, 2rem)`;
115
+ const scrollOffset = css`var(--modalScrollOffset, 5px)`;
116
+
117
+ const titleFontSize = css`var(--modalTitleFontSize, 1.8rem)`;
118
+ const subtitleFontSize = css`var(--modalSubtitleFontSize, 1.4rem)`;
119
+ const headlineFontSize = css`var(--modalHeadlineFontSize, 1.6rem)`;
120
+ const messageFontSize = css`var(--modalMessageFontSize, 1.4rem)`;
121
+
122
+ const titleLineHeight = css`var(--modalTitleLineHeight, normal)`;
123
+ const subtitleLineHeight = css`var(--modalSubtitleLineHeight, normal)`;
124
+ const headlineLineHeight = css`var(--modalHeadlineLineHeight, normal)`;
125
+ const messageLineHeight = css`var(--modalMessageLineHeight, normal)`;
126
+
127
+ return css`
128
+ .processing-logo {
129
+ margin: auto;
130
+ width: ${processingImageSize};
131
+ height: ${processingImageSize};
132
+ }
133
+
134
+ .processing-logo.hidden {
135
+ height: 1rem;
136
+ }
137
+
138
+ .processing-logo.hidden ia-activity-indicator {
139
+ display: none;
140
+ }
141
+
142
+ .modal-wrapper {
143
+ outline: none;
144
+ }
145
+
146
+ .modal-container {
147
+ border-radius: ${modalCornerRadius};
148
+ width: 100%;
149
+ margin-top: ${modalTopMarginCss};
150
+ }
151
+
152
+ header {
153
+ position: relative;
154
+ background-color: #36a483;
155
+ color: white;
156
+ border-radius: calc(${modalCornerRadius}) calc(${modalCornerRadius}) 0 0;
157
+ border: ${modalBorder};
158
+ border-bottom: 0;
159
+ text-align: center;
160
+ padding-bottom: ${modalHeaderBottomPaddingCss};
161
+ }
162
+
163
+ .title {
164
+ margin: 0;
165
+ padding: 0;
166
+ font-size: ${titleFontSize};
167
+ font-weight: bold;
168
+ line-height: ${titleLineHeight};
169
+ }
170
+
171
+ .subtitle {
172
+ margin: 0;
173
+ padding: 0;
174
+ font-weight: normal;
175
+ padding-top: 0;
176
+ font-size: ${subtitleFontSize};
177
+ line-height: ${subtitleLineHeight};
178
+ }
179
+
180
+ .modal-body {
181
+ background-color: #f5f5f7;
182
+ border-radius: 0 0 calc(${modalCornerRadius}) calc(${modalCornerRadius});
183
+ border: ${modalBorder};
184
+ border-top: 0;
185
+ padding: 0 1rem calc(${modalBottomPadding} - ${scrollOffset}) 1rem;
186
+ color: #333;
187
+ margin-bottom: 2.5rem;
188
+ min-height: 5rem;
189
+ }
190
+
191
+ .content {
192
+ overflow-y: auto;
193
+ max-height: calc(100vh - (16.5rem + ${modalBottomMarginCss}));
194
+ min-height: 5rem;
195
+ padding: 0 0 calc(${scrollOffset}) 0;
196
+ }
197
+
198
+ .headline {
199
+ font-size: ${headlineFontSize};
200
+ font-weight: bold;
201
+ text-align: center;
202
+ line-height: ${headlineLineHeight};
203
+ margin: 0;
204
+ padding: 0;
205
+ }
206
+
207
+ .message {
208
+ margin: 1rem 0 0 0;
209
+ text-align: center;
210
+ font-size: ${messageFontSize};
211
+ line-height: ${messageLineHeight};
212
+ }
213
+
214
+ .logo-icon {
215
+ border-radius: 100%;
216
+ border: 3px solid #fff;
217
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),
218
+ 0 2px 2px 0 rgba(0, 0, 0, 0.08);
219
+ width: ${modalLogoSize};
220
+ height: ${modalLogoSize};
221
+ margin: -2.9rem auto 0.5rem auto;
222
+ background-color: black;
223
+ display: flex;
224
+ justify-content: center;
225
+ align-items: center;
226
+ }
227
+
228
+ .logo-icon svg {
229
+ width: calc(${modalLogoSize} * 0.65);
230
+ height: calc(${modalLogoSize} * 0.65);
231
+ }
232
+
233
+ .logo-icon svg .fill-color {
234
+ fill: white;
235
+ }
236
+
237
+ .logo-icon svg .stroke-color {
238
+ stroke: red;
239
+ }
240
+
241
+ .close-button {
242
+ position: absolute;
243
+ right: 1.2rem;
244
+ top: 1.2rem;
245
+ width: 2rem;
246
+ height: 2rem;
247
+ border-radius: 100%;
248
+ border: 0;
249
+ padding: 0;
250
+ cursor: pointer;
251
+ background-color: white;
252
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),
253
+ 0 4px 4px 0 rgba(0, 0, 0, 0.08);
254
+ }
255
+
256
+ .sr-only {
257
+ position: absolute;
258
+ width: 1px;
259
+ height: 1px;
260
+ padding: 0;
261
+ margin: -1px;
262
+ overflow: hidden;
263
+ clip: rect(0, 0, 0, 0);
264
+ border: 0;
265
+ }
266
+
267
+ slot::slotted(.sr-only) {
268
+ position: absolute;
269
+ width: 1px;
270
+ height: 1px;
271
+ padding: 0;
272
+ margin: -1px;
273
+ overflow: hidden;
274
+ clip: rect(0, 0, 0, 0);
275
+ border: 0;
276
+ }
277
+ `;
278
+ }
279
+ }