Skip to content

Commit 5e7d927

Browse files
authored
refactor: update login overlay to not use dom-module (#4946)
1 parent c092726 commit 5e7d927

2 files changed

Lines changed: 47 additions & 52 deletions

File tree

‎packages/login/src/vaadin-login-overlay-wrapper.js‎

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,56 @@
33
* Copyright (c) 2018 - 2022 Vaadin Ltd.
44
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
55
*/
6-
import { DomModule } from '@polymer/polymer/lib/elements/dom-module.js';
6+
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
77
import { Overlay } from '@vaadin/overlay/src/vaadin-overlay.js';
8+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
89

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+
}
1716
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+
}
2524
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+
}
3534
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+
);
5442

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+
`;
5656

5757
let memoizedTemplate;
5858

@@ -90,15 +90,10 @@ class LoginOverlayWrapper extends Overlay {
9090
// Clone the superclass template
9191
memoizedTemplate = super.template.cloneNode(true);
9292

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]');
9995
const content = memoizedTemplate.content.querySelector('#content');
10096
content.replaceChild(card, content.children[0]);
101-
content.appendChild(styles);
10297
}
10398

10499
return memoizedTemplate;

‎packages/login/theme/material/vaadin-login-overlay-styles.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ const loginOverlayWrapper = css`
302302
`;
303303

304304
registerStyles('vaadin-login-overlay-wrapper', [overlay, typography, loginOverlayWrapper], {
305-
moduleId: 'vaadin-login-overlay-wrapper-material-styles',
305+
moduleId: 'material-login-overlay-wrapper',
306306
});
307307

308308
const loginFormWrapper = css`

0 commit comments

Comments
 (0)