@internetarchive/modal-manager 0.2.6 → 0.2.7
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/README.md +3 -1
- package/demo/index.html +2 -0
- package/dist/src/modal-manager-host-bridge.js +1 -1
- package/dist/src/modal-manager-host-bridge.js.map +1 -1
- package/dist/src/modal-template.js +22 -0
- package/dist/src/modal-template.js.map +1 -1
- package/package.json +1 -1
- package/src/modal-manager-host-bridge.ts +1 -1
- package/src/modal-template.ts +22 -0
package/README.md
CHANGED
|
@@ -90,11 +90,13 @@ Display completely custom content in the modal body, including light DOM content
|
|
|
90
90
|
const customContent = html`
|
|
91
91
|
Can contain any markup, including web components. Event listeners also work. Try clicking on the picture.
|
|
92
92
|
<div style="text-align: center">
|
|
93
|
+
<div class="sr-only">Visible for screen-readers only</div>
|
|
93
94
|
<a href="https://fillmurray.com" style="display: block">Fill Murray</a>
|
|
94
95
|
<img src="100x100.jpg" @click=${showBillAlert} />
|
|
95
96
|
</div>
|
|
96
97
|
`;
|
|
97
98
|
|
|
99
|
+
// customContent used to render as slotted content, it can also use .sr-only class
|
|
98
100
|
modalManager.showModal(config, customContent);
|
|
99
101
|
</script>
|
|
100
102
|
```
|
|
@@ -107,7 +109,7 @@ All of the config options:
|
|
|
107
109
|
const config = new ModalConfig();
|
|
108
110
|
config.title = 'Internet Archive';
|
|
109
111
|
config.subtitle = '';
|
|
110
|
-
config.headline = 'Thanks for your Support!';
|
|
112
|
+
config.headline = '<div class="sr-only">Visible for screen-readers only</div>Thanks for your Support!';
|
|
111
113
|
config.message = 'Thank you for supporting the Internet Archive!';
|
|
112
114
|
config.headerColor = '#36A483';
|
|
113
115
|
config.showProcessingIndicator = false;
|
package/demo/index.html
CHANGED
|
@@ -151,9 +151,11 @@
|
|
|
151
151
|
function showCustomContentModal() {
|
|
152
152
|
const config = new ModalConfig();
|
|
153
153
|
config.title = 'Custom Content';
|
|
154
|
+
config.headline = html`<span class="sr-only">Also support screen-reader only</span>`;
|
|
154
155
|
|
|
155
156
|
const someContent = html`
|
|
156
157
|
Can contain any markup, including web components. Event listeners also work. Try clicking on the picture.
|
|
158
|
+
<span class="sr-only">Also support screen-reader only</span>
|
|
157
159
|
<div style="text-align: center">
|
|
158
160
|
<a href="https://fillmurray.com" style="display: block">Fill Murray</a>
|
|
159
161
|
<img src="100x100.jpg" @click=${showBillAlert} />
|
|
@@ -16,7 +16,7 @@ import { ModalManagerMode } from './modal-manager-mode';
|
|
|
16
16
|
*/
|
|
17
17
|
export class ModalManagerHostBridge {
|
|
18
18
|
constructor(modalManager) {
|
|
19
|
-
this.windowResizeThrottler = throttle(100, this.updateModalContainerHeight
|
|
19
|
+
this.windowResizeThrottler = throttle(100, this.updateModalContainerHeight).bind(this);
|
|
20
20
|
this.modalManager = modalManager;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-manager-host-bridge.js","sourceRoot":"","sources":["../../src/modal-manager-host-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,sBAAsB;IAGjC,YAAY,YAAmC;QAuBvC,0BAAqB,GAAyB,QAAQ,CAC5D,GAAG,EACH,IAAI,CAAC,0BAA0B,
|
|
1
|
+
{"version":3,"file":"modal-manager-host-bridge.js","sourceRoot":"","sources":["../../src/modal-manager-host-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,sBAAsB;IAGjC,YAAY,YAAmC;QAuBvC,0BAAqB,GAAyB,QAAQ,CAC5D,GAAG,EACH,IAAI,CAAC,0BAA0B,CAEhC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QA1BX,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,IAAsB;QACrC,QAAQ,IAAI,EAAE;YACZ,KAAK,gBAAgB,CAAC,IAAI;gBACxB,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBAC3B,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBAC1B,MAAM;YACR,KAAK,gBAAgB,CAAC,MAAM;gBAC1B,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBAC1B,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC5B,MAAM;SACT;IACH,CAAC;IAQD,yFAAyF;IACzF,mGAAmG;IACnG,mGAAmG;IACnG,kBAAkB;IAClB,0FAA0F;IAC1F,qFAAqF;IACrF,yCAAyC;IACjC,0BAA0B;QAChC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CACjC,mBAAmB,EACnB,GAAG,MAAM,CAAC,WAAW,IAAI,CAC1B,CAAC;IACJ,CAAC;IAEO,kBAAkB;QACxB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACpD,CAAC;IAEO,oBAAoB;QAC1B,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACvD,CAAC;IAEO,mBAAmB;QACzB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAChE,CAAC;IAEO,kBAAkB;QACxB,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["import { throttle } from 'throttle-debounce';\n\nimport { ModalManagerHostBridgeInterface } from './modal-manager-host-bridge-interface';\nimport { ModalManagerInterface } from './modal-manager-interface';\nimport { ModalManagerMode } from './modal-manager-mode';\n\n/**\n * The `ModalManagerHostBridge` is a bridge between the `ModalManager` and the\n * host that sets up environment-specific changes when the modal opens and closes.\n *\n * For instance, when the modal opens, this adds a class to the `<body>` tag for styling\n * and adds a `resize` listener to fix a Safari shadow root issue.\n *\n * Consumers can create their own `ModalManagerHostBridgeInterface` classes and pass\n * them into the `ModalManager` if this one does not work for their environment.\n *\n * @export\n * @class ModalManagerHostBridge\n * @implements {ModalManagerHostBridgeInterface}\n */\nexport class ModalManagerHostBridge implements ModalManagerHostBridgeInterface {\n private modalManager: ModalManagerInterface;\n\n constructor(modalManager: ModalManagerInterface) {\n this.modalManager = modalManager;\n }\n\n /**\n * Handle the mode change\n *\n * @private\n * @memberof ModalManager\n */\n handleModeChange(mode: ModalManagerMode): void {\n switch (mode) {\n case ModalManagerMode.Open:\n this.startResizeListener();\n this.stopDocumentScroll();\n break;\n case ModalManagerMode.Closed:\n this.stopResizeListener();\n this.resumeDocumentScroll();\n break;\n }\n }\n\n private windowResizeThrottler: throttle<() => void> = throttle(\n 100,\n this.updateModalContainerHeight,\n // { noLeading: false, noTrailing: false }\n ).bind(this);\n\n // This is a workaround for Safari. Safari does not update shadowRoot elements calculated\n // based on the viewport size (ie. `calc(100vh - 10px)`). It does an initial calculation correctly,\n // but resizing the window does not cause the calculation to update. Firefox and Chrome both handle\n // this correctly.\n // It doesn't matter what css variable you set, it is just forcing Safari to do an update.\n // Also note that the value has to change on each update for Safari to do the update,\n // ie. you can't just set a static value.\n private updateModalContainerHeight(): void {\n this.modalManager.style.setProperty(\n '--containerHeight',\n `${window.innerHeight}px`\n );\n }\n\n private stopDocumentScroll(): void {\n document.body.classList.add('modal-manager-open');\n }\n\n private resumeDocumentScroll(): void {\n document.body.classList.remove('modal-manager-open');\n }\n\n private startResizeListener(): void {\n window.addEventListener('resize', this.windowResizeThrottler);\n }\n\n private stopResizeListener(): void {\n window.removeEventListener('resize', this.windowResizeThrottler);\n }\n}\n"]}
|
|
@@ -242,6 +242,28 @@ let ModalTemplate = class ModalTemplate extends LitElement {
|
|
|
242
242
|
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),
|
|
243
243
|
0 4px 4px 0 rgba(0, 0, 0, 0.08);
|
|
244
244
|
}
|
|
245
|
+
|
|
246
|
+
.sr-only {
|
|
247
|
+
position: absolute;
|
|
248
|
+
width: 1px;
|
|
249
|
+
height: 1px;
|
|
250
|
+
padding: 0;
|
|
251
|
+
margin: -1px;
|
|
252
|
+
overflow: hidden;
|
|
253
|
+
clip: rect(0, 0, 0, 0);
|
|
254
|
+
border: 0;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
slot::slotted(.sr-only) {
|
|
258
|
+
position: absolute;
|
|
259
|
+
width: 1px;
|
|
260
|
+
height: 1px;
|
|
261
|
+
padding: 0;
|
|
262
|
+
margin: -1px;
|
|
263
|
+
overflow: hidden;
|
|
264
|
+
clip: rect(0, 0, 0, 0);
|
|
265
|
+
border: 0;
|
|
266
|
+
}
|
|
245
267
|
`;
|
|
246
268
|
}
|
|
247
269
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-template.js","sourceRoot":"","sources":["../../src/modal-template.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6B,OAAO,EAAE,MAAM,KAAK,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,8DAA8D,CAAC;AACtE,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,MAAM,MAAM,+BAA+B,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,UAAU;IAA7C;;QACE;;;;;WAKG;QACyB,WAAM,GAAgB,IAAI,WAAW,EAAE,CAAC;IA+OtE,CAAC;IA7OC,kBAAkB;IAClB,MAAM;Q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2B;;;;;;qBAMhC,aAAa;;uBAEX,eAAe;;;;;;;;qBAQjB,gBAAgB;uBACd,kBAAkB;;;;;kCAKP,iBAAiB,UAAU,iBAAiB;kBAC5D,WAAW;;+BAEE,kBAAkB,MAAM,YAAY;;;;;;;;8CAQrB,oBAAoB;;4BAEtC,YAAY;;;;qBAInB,gBAAgB;;;uBAGd,kBAAkB;;;;;;;;qBAQpB,eAAe;uBACb,iBAAiB;;;;;;;;iBAQvB,aAAa;kBACZ,aAAa;;;;;;;;;sBAST,aAAa;uBACZ,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;KAyB/B,CAAC;IACJ,CAAC;CACF,CAAA;AA/O6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAyC;AAPzD,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAsPzB;SAtPY,aAAa","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult, nothing } from 'lit';\nimport { property, customElement } from 'lit/decorators.js';\n\nimport '@internetarchive/ia-activity-indicator/ia-activity-indicator';\nimport closeIcon from '@internetarchive/icon-close';\nimport iaLogo from '@internetarchive/icon-ia-logo';\n\nimport { ModalConfig } from './modal-config';\n\n@customElement('modal-template')\nexport class ModalTemplate extends LitElement {\n /**\n * The ModalConfig that displayed the template\n *\n * @type {ModalConfig}\n * @memberof ModalTemplate\n */\n @property({ type: Object }) config: ModalConfig = new ModalConfig();\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div class=\"modal-wrapper\">\n <div class=\"modal-container\">\n <header style=\"background-color: ${this.config.headerColor}\">\n ${this.config.showCloseButton ? this.closeButtonTemplate : ''}\n ${this.config.showHeaderLogo\n ? html`<div class=\"logo-icon\">${iaLogo}</div>`\n : nothing}\n ${this.config.title\n ? html`<h1 class=\"title\">${this.config.title}</h1>`\n : ''}\n ${this.config.subtitle\n ? html`<h2 class=\"subtitle\">${this.config.subtitle}</h2>`\n : ''}\n </header>\n <section\n class=\"modal-body\"\n style=\"background-color: ${this.config.bodyColor}\"\n >\n <div class=\"content\">\n <div\n class=\"processing-logo ${this.config.showProcessingIndicator\n ? ''\n : 'hidden'}\"\n >\n <ia-activity-indicator\n .mode=${this.config.processingImageMode}\n ></ia-activity-indicator>\n </div>\n ${this.config.headline\n ? html` <h1 class=\"headline\">${this.config.headline}</h1> `\n : ''}\n ${this.config.message\n ? html` <p class=\"message\">${this.config.message}</p> `\n : ''}\n\n <div class=\"slot-container\">\n <slot> </slot>\n </div>\n </div>\n </section>\n </div>\n </div>\n `;\n }\n\n /**\n * Dispatch the `closeButtonPressed` event to the consumer\n *\n * @private\n * @memberof ModalTemplate\n */\n private handleCloseButton(): void {\n const event = new Event('closeButtonPressed');\n this.dispatchEvent(event);\n }\n\n /**\n * The close button template\n *\n * @readonly\n * @private\n * @type {TemplateResult}\n * @memberof ModalTemplate\n */\n private get closeButtonTemplate(): TemplateResult {\n return html`\n <button\n type=\"button\"\n class=\"close-button\"\n tabindex=\"0\"\n @click=${this.handleCloseButton}\n >\n ${closeIcon}\n </button>\n `;\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const modalLogoSize = css`var(--modalLogoSize, 6.5rem)`;\n\n const processingImageSize = css`var(--processingImageSize, 7.5rem)`;\n\n const modalCornerRadius = css`var(--modalCornerRadius, 1rem)`;\n const modalBorder = css`var(--modalBorder, 2px solid black)`;\n // if the content of the modal is too big to fit on screen, this sets the bottom margin\n // it's not exact, but a close estimation\n const modalBottomMarginCss = css`var(--modalBottomMargin, 2.5rem)`;\n const modalTopMarginCss = css`var(--modalTopMargin, 5rem)`;\n const modalHeaderBottomPaddingCss = css`var(--modalHeaderBottomPadding, 0.5em)`;\n\n const modalBottomPadding = css`var(--modalBottomPadding, 2rem)`;\n const scrollOffset = css`var(--modalScrollOffset, 5px)`;\n\n const titleFontSize = css`var(--modalTitleFontSize, 1.8rem)`;\n const subtitleFontSize = css`var(--modalSubtitleFontSize, 1.4rem)`;\n const headlineFontSize = css`var(--modalHeadlineFontSize, 1.6rem)`;\n const messageFontSize = css`var(--modalMessageFontSize, 1.4rem)`;\n\n const titleLineHeight = css`var(--modalTitleLineHeight, normal)`;\n const subtitleLineHeight = css`var(--modalSubtitleLineHeight, normal)`;\n const headlineLineHeight = css`var(--modalHeadlineLineHeight, normal)`;\n const messageLineHeight = css`var(--modalMessageLineHeight, normal)`;\n\n return css`\n .processing-logo {\n margin: auto;\n width: ${processingImageSize};\n height: ${processingImageSize};\n }\n\n .processing-logo.hidden {\n height: 1rem;\n }\n\n .processing-logo.hidden ia-activity-indicator {\n display: none;\n }\n\n .modal-wrapper {\n outline: none;\n }\n\n .modal-container {\n border-radius: ${modalCornerRadius};\n width: 100%;\n margin-top: ${modalTopMarginCss};\n }\n\n header {\n position: relative;\n background-color: #36a483;\n color: white;\n border-radius: calc(${modalCornerRadius}) calc(${modalCornerRadius}) 0 0;\n border: ${modalBorder};\n border-bottom: 0;\n text-align: center;\n padding-bottom: ${modalHeaderBottomPaddingCss};\n }\n\n .title {\n margin: 0;\n padding: 0;\n font-size: ${titleFontSize};\n font-weight: bold;\n line-height: ${titleLineHeight};\n }\n\n .subtitle {\n margin: 0;\n padding: 0;\n font-weight: normal;\n padding-top: 0;\n font-size: ${subtitleFontSize};\n line-height: ${subtitleLineHeight};\n }\n\n .modal-body {\n background-color: #f5f5f7;\n border-radius: 0 0 calc(${modalCornerRadius}) calc(${modalCornerRadius});\n border: ${modalBorder};\n border-top: 0;\n padding: 0 1rem calc(${modalBottomPadding} - ${scrollOffset}) 1rem;\n color: #333;\n margin-bottom: 2.5rem;\n min-height: 5rem;\n }\n\n .content {\n overflow-y: auto;\n max-height: calc(100vh - (16.5rem + ${modalBottomMarginCss}));\n min-height: 5rem;\n padding: 0 0 calc(${scrollOffset}) 0;\n }\n\n .headline {\n font-size: ${headlineFontSize};\n font-weight: bold;\n text-align: center;\n line-height: ${headlineLineHeight};\n margin: 0;\n padding: 0;\n }\n\n .message {\n margin: 1rem 0 0 0;\n text-align: center;\n font-size: ${messageFontSize};\n line-height: ${messageLineHeight};\n }\n\n .logo-icon {\n border-radius: 100%;\n border: 3px solid #fff;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),\n 0 2px 2px 0 rgba(0, 0, 0, 0.08);\n width: ${modalLogoSize};\n height: ${modalLogoSize};\n margin: -2.9rem auto 0.5rem auto;\n background-color: black;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .logo-icon svg {\n width: calc(${modalLogoSize} * 0.65);\n height: calc(${modalLogoSize} * 0.65);\n }\n\n .logo-icon svg .fill-color {\n fill: white;\n }\n\n .logo-icon svg .stroke-color {\n stroke: red;\n }\n\n .close-button {\n position: absolute;\n right: 1.2rem;\n top: 1.2rem;\n width: 2rem;\n height: 2rem;\n border-radius: 100%;\n border: 0;\n padding: 0;\n cursor: pointer;\n background-color: white;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),\n 0 4px 4px 0 rgba(0, 0, 0, 0.08);\n }\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"modal-template.js","sourceRoot":"","sources":["../../src/modal-template.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6B,OAAO,EAAE,MAAM,KAAK,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,8DAA8D,CAAC;AACtE,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,MAAM,MAAM,+BAA+B,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,UAAU;IAA7C;;QACE;;;;;WAKG;QACyB,WAAM,GAAgB,IAAI,WAAW,EAAE,CAAC;IAqQtE,CAAC;IAnQC,kBAAkB;IAClB,MAAM;QACJ,OAAO,IAAI,CAAA;;;6CAG8B,IA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e;;;;;;;;qBAQjB,gBAAgB;uBACd,kBAAkB;;;;;kCAKP,iBAAiB,UAAU,iBAAiB;kBAC5D,WAAW;;+BAEE,kBAAkB,MAAM,YAAY;;;;;;;;8CAQrB,oBAAoB;;4BAEtC,YAAY;;;;qBAInB,gBAAgB;;;uBAGd,kBAAkB;;;;;;;;qBAQpB,eAAe;uBACb,iBAAiB;;;;;;;;iBAQvB,aAAa;kBACZ,aAAa;;;;;;;;;sBAST,aAAa;uBACZ,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+C/B,CAAC;IACJ,CAAC;CACF,CAAA;AArQ6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAyC;AAPzD,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CA4QzB;SA5QY,aAAa","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult, nothing } from 'lit';\nimport { property, customElement } from 'lit/decorators.js';\n\nimport '@internetarchive/ia-activity-indicator/ia-activity-indicator';\nimport closeIcon from '@internetarchive/icon-close';\nimport iaLogo from '@internetarchive/icon-ia-logo';\n\nimport { ModalConfig } from './modal-config';\n\n@customElement('modal-template')\nexport class ModalTemplate extends LitElement {\n /**\n * The ModalConfig that displayed the template\n *\n * @type {ModalConfig}\n * @memberof ModalTemplate\n */\n @property({ type: Object }) config: ModalConfig = new ModalConfig();\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div class=\"modal-wrapper\">\n <div class=\"modal-container\">\n <header style=\"background-color: ${this.config.headerColor}\">\n ${this.config.showCloseButton ? this.closeButtonTemplate : ''}\n ${this.config.showHeaderLogo\n ? html`<div class=\"logo-icon\">${iaLogo}</div>`\n : nothing}\n ${this.config.title\n ? html`<h1 class=\"title\">${this.config.title}</h1>`\n : ''}\n ${this.config.subtitle\n ? html`<h2 class=\"subtitle\">${this.config.subtitle}</h2>`\n : ''}\n </header>\n <section\n class=\"modal-body\"\n style=\"background-color: ${this.config.bodyColor}\"\n >\n <div class=\"content\">\n <div\n class=\"processing-logo ${this.config.showProcessingIndicator\n ? ''\n : 'hidden'}\"\n >\n <ia-activity-indicator\n .mode=${this.config.processingImageMode}\n ></ia-activity-indicator>\n </div>\n ${this.config.headline\n ? html` <h1 class=\"headline\">${this.config.headline}</h1> `\n : ''}\n ${this.config.message\n ? html` <p class=\"message\">${this.config.message}</p> `\n : ''}\n\n <div class=\"slot-container\">\n <slot> </slot>\n </div>\n </div>\n </section>\n </div>\n </div>\n `;\n }\n\n /**\n * Dispatch the `closeButtonPressed` event to the consumer\n *\n * @private\n * @memberof ModalTemplate\n */\n private handleCloseButton(): void {\n const event = new Event('closeButtonPressed');\n this.dispatchEvent(event);\n }\n\n /**\n * The close button template\n *\n * @readonly\n * @private\n * @type {TemplateResult}\n * @memberof ModalTemplate\n */\n private get closeButtonTemplate(): TemplateResult {\n return html`\n <button\n type=\"button\"\n class=\"close-button\"\n tabindex=\"0\"\n @click=${this.handleCloseButton}\n >\n ${closeIcon}\n </button>\n `;\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const modalLogoSize = css`var(--modalLogoSize, 6.5rem)`;\n\n const processingImageSize = css`var(--processingImageSize, 7.5rem)`;\n\n const modalCornerRadius = css`var(--modalCornerRadius, 1rem)`;\n const modalBorder = css`var(--modalBorder, 2px solid black)`;\n // if the content of the modal is too big to fit on screen, this sets the bottom margin\n // it's not exact, but a close estimation\n const modalBottomMarginCss = css`var(--modalBottomMargin, 2.5rem)`;\n const modalTopMarginCss = css`var(--modalTopMargin, 5rem)`;\n const modalHeaderBottomPaddingCss = css`var(--modalHeaderBottomPadding, 0.5em)`;\n\n const modalBottomPadding = css`var(--modalBottomPadding, 2rem)`;\n const scrollOffset = css`var(--modalScrollOffset, 5px)`;\n\n const titleFontSize = css`var(--modalTitleFontSize, 1.8rem)`;\n const subtitleFontSize = css`var(--modalSubtitleFontSize, 1.4rem)`;\n const headlineFontSize = css`var(--modalHeadlineFontSize, 1.6rem)`;\n const messageFontSize = css`var(--modalMessageFontSize, 1.4rem)`;\n\n const titleLineHeight = css`var(--modalTitleLineHeight, normal)`;\n const subtitleLineHeight = css`var(--modalSubtitleLineHeight, normal)`;\n const headlineLineHeight = css`var(--modalHeadlineLineHeight, normal)`;\n const messageLineHeight = css`var(--modalMessageLineHeight, normal)`;\n\n return css`\n .processing-logo {\n margin: auto;\n width: ${processingImageSize};\n height: ${processingImageSize};\n }\n\n .processing-logo.hidden {\n height: 1rem;\n }\n\n .processing-logo.hidden ia-activity-indicator {\n display: none;\n }\n\n .modal-wrapper {\n outline: none;\n }\n\n .modal-container {\n border-radius: ${modalCornerRadius};\n width: 100%;\n margin-top: ${modalTopMarginCss};\n }\n\n header {\n position: relative;\n background-color: #36a483;\n color: white;\n border-radius: calc(${modalCornerRadius}) calc(${modalCornerRadius}) 0 0;\n border: ${modalBorder};\n border-bottom: 0;\n text-align: center;\n padding-bottom: ${modalHeaderBottomPaddingCss};\n }\n\n .title {\n margin: 0;\n padding: 0;\n font-size: ${titleFontSize};\n font-weight: bold;\n line-height: ${titleLineHeight};\n }\n\n .subtitle {\n margin: 0;\n padding: 0;\n font-weight: normal;\n padding-top: 0;\n font-size: ${subtitleFontSize};\n line-height: ${subtitleLineHeight};\n }\n\n .modal-body {\n background-color: #f5f5f7;\n border-radius: 0 0 calc(${modalCornerRadius}) calc(${modalCornerRadius});\n border: ${modalBorder};\n border-top: 0;\n padding: 0 1rem calc(${modalBottomPadding} - ${scrollOffset}) 1rem;\n color: #333;\n margin-bottom: 2.5rem;\n min-height: 5rem;\n }\n\n .content {\n overflow-y: auto;\n max-height: calc(100vh - (16.5rem + ${modalBottomMarginCss}));\n min-height: 5rem;\n padding: 0 0 calc(${scrollOffset}) 0;\n }\n\n .headline {\n font-size: ${headlineFontSize};\n font-weight: bold;\n text-align: center;\n line-height: ${headlineLineHeight};\n margin: 0;\n padding: 0;\n }\n\n .message {\n margin: 1rem 0 0 0;\n text-align: center;\n font-size: ${messageFontSize};\n line-height: ${messageLineHeight};\n }\n\n .logo-icon {\n border-radius: 100%;\n border: 3px solid #fff;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),\n 0 2px 2px 0 rgba(0, 0, 0, 0.08);\n width: ${modalLogoSize};\n height: ${modalLogoSize};\n margin: -2.9rem auto 0.5rem auto;\n background-color: black;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .logo-icon svg {\n width: calc(${modalLogoSize} * 0.65);\n height: calc(${modalLogoSize} * 0.65);\n }\n\n .logo-icon svg .fill-color {\n fill: white;\n }\n\n .logo-icon svg .stroke-color {\n stroke: red;\n }\n\n .close-button {\n position: absolute;\n right: 1.2rem;\n top: 1.2rem;\n width: 2rem;\n height: 2rem;\n border-radius: 100%;\n border: 0;\n padding: 0;\n cursor: pointer;\n background-color: white;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),\n 0 4px 4px 0 rgba(0, 0, 0, 0.08);\n }\n\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n }\n\n slot::slotted(.sr-only) {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n }\n `;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -47,7 +47,7 @@ export class ModalManagerHostBridge implements ModalManagerHostBridgeInterface {
|
|
|
47
47
|
private windowResizeThrottler: throttle<() => void> = throttle(
|
|
48
48
|
100,
|
|
49
49
|
this.updateModalContainerHeight,
|
|
50
|
-
{ noLeading: false, noTrailing: false }
|
|
50
|
+
// { noLeading: false, noTrailing: false }
|
|
51
51
|
).bind(this);
|
|
52
52
|
|
|
53
53
|
// This is a workaround for Safari. Safari does not update shadowRoot elements calculated
|
package/src/modal-template.ts
CHANGED
|
@@ -252,6 +252,28 @@ export class ModalTemplate extends LitElement {
|
|
|
252
252
|
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),
|
|
253
253
|
0 4px 4px 0 rgba(0, 0, 0, 0.08);
|
|
254
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
|
+
}
|
|
255
277
|
`;
|
|
256
278
|
}
|
|
257
279
|
}
|