|
3 | 3 | * Copyright (c) 2018 - 2022 Vaadin Ltd. |
4 | 4 | * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ |
5 | 5 | */ |
6 | | -import { DomModule } from '@polymer/polymer/lib/elements/dom-module.js'; |
| 6 | +import { html } from '@polymer/polymer/lib/utils/html-tag.js'; |
7 | 7 | import { Overlay } from '@vaadin/overlay/src/vaadin-overlay.js'; |
| 8 | +import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; |
8 | 9 |
|
9 | | -const template = document.createElement('template'); |
10 | | - |
11 | | -template.innerHTML = `<dom-module id="vaadin-login-overlay-wrapper-template"> |
12 | | - <template> |
13 | | - <style> |
14 | | - [part="overlay"] { |
15 | | - outline: none; |
16 | | - } |
| 10 | +registerStyles( |
| 11 | + 'vaadin-login-overlay-wrapper', |
| 12 | + css` |
| 13 | + [part='overlay'] { |
| 14 | + outline: none; |
| 15 | + } |
17 | 16 |
|
18 | | - [part="card"] { |
19 | | - max-width: 100%; |
20 | | - box-sizing: border-box; |
21 | | - overflow: hidden; |
22 | | - display: flex; |
23 | | - flex-direction: column; |
24 | | - } |
| 17 | + [part='card'] { |
| 18 | + max-width: 100%; |
| 19 | + box-sizing: border-box; |
| 20 | + overflow: hidden; |
| 21 | + display: flex; |
| 22 | + flex-direction: column; |
| 23 | + } |
25 | 24 |
|
26 | | - [part="brand"] { |
27 | | - box-sizing: border-box; |
28 | | - overflow: hidden; |
29 | | - flex-grow: 1; |
30 | | - flex-shrink: 0; |
31 | | - display: flex; |
32 | | - flex-direction: column; |
33 | | - justify-content: flex-end; |
34 | | - } |
| 25 | + [part='brand'] { |
| 26 | + box-sizing: border-box; |
| 27 | + overflow: hidden; |
| 28 | + flex-grow: 1; |
| 29 | + flex-shrink: 0; |
| 30 | + display: flex; |
| 31 | + flex-direction: column; |
| 32 | + justify-content: flex-end; |
| 33 | + } |
35 | 34 |
|
36 | | - [part="brand"] h1 { |
37 | | - color: inherit; |
38 | | - margin: 0; |
39 | | - } |
40 | | - </style> |
41 | | - <section part="card"> |
42 | | - <div part="brand"> |
43 | | - <slot name="title"> |
44 | | - <h1 part="title">[[title]]</h1> |
45 | | - </slot> |
46 | | - <p part="description">[[description]]</p> |
47 | | - </div> |
48 | | - <div part="form"> |
49 | | - <slot></slot> |
50 | | - </div> |
51 | | - </section> |
52 | | - </template> |
53 | | -</dom-module>`; |
| 35 | + [part='brand'] h1 { |
| 36 | + color: inherit; |
| 37 | + margin: 0; |
| 38 | + } |
| 39 | + `, |
| 40 | + { moduleId: 'vaadin-login-overlay-wrapper-styles' }, |
| 41 | +); |
54 | 42 |
|
55 | | -document.head.appendChild(template.content); |
| 43 | +const template = html` |
| 44 | + <section part="card"> |
| 45 | + <div part="brand"> |
| 46 | + <slot name="title"> |
| 47 | + <h1 part="title">[[title]]</h1> |
| 48 | + </slot> |
| 49 | + <p part="description">[[description]]</p> |
| 50 | + </div> |
| 51 | + <div part="form"> |
| 52 | + <slot></slot> |
| 53 | + </div> |
| 54 | + </section> |
| 55 | +`; |
56 | 56 |
|
57 | 57 | let memoizedTemplate; |
58 | 58 |
|
@@ -90,15 +90,10 @@ class LoginOverlayWrapper extends Overlay { |
90 | 90 | // Clone the superclass template |
91 | 91 | memoizedTemplate = super.template.cloneNode(true); |
92 | 92 |
|
93 | | - // Retrieve the elements from component's template |
94 | | - const thisTemplate = DomModule.import(`${this.is}-template`, 'template'); |
95 | | - const card = thisTemplate.content.querySelector('[part=card]'); |
96 | | - const styles = thisTemplate.content.querySelector('style'); |
97 | | - |
98 | | - // Append elements to cloned template |
| 93 | + // Replace overlay slot with card |
| 94 | + const card = template.content.querySelector('[part=card]'); |
99 | 95 | const content = memoizedTemplate.content.querySelector('#content'); |
100 | 96 | content.replaceChild(card, content.children[0]); |
101 | | - content.appendChild(styles); |
102 | 97 | } |
103 | 98 |
|
104 | 99 | return memoizedTemplate; |
|
0 commit comments