2023-09-09 11:34:46 +00:00
|
|
|
import { demoFunc } from './dees-simple-login.demo.js';
|
|
|
|
|
2023-08-19 09:47:45 +00:00
|
|
|
import {
|
|
|
|
customElement,
|
|
|
|
html,
|
|
|
|
DeesElement,
|
|
|
|
property,
|
|
|
|
type TemplateResult,
|
|
|
|
cssManager,
|
|
|
|
css,
|
|
|
|
unsafeCSS,
|
|
|
|
type CSSResult,
|
|
|
|
state,
|
|
|
|
} from '@design.estate/dees-element';
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
interface HTMLElementTagNameMap {
|
|
|
|
'dees-simple-login': DeesSimpleLogin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@customElement('dees-simple-login')
|
|
|
|
export class DeesSimpleLogin extends DeesElement {
|
|
|
|
// STATIC
|
2023-09-09 11:34:46 +00:00
|
|
|
public static demo = demoFunc
|
2023-08-19 09:47:45 +00:00
|
|
|
// INSTANCE
|
|
|
|
|
|
|
|
@property()
|
2023-09-12 23:37:02 +00:00
|
|
|
public name = 'Dees Simple Login';
|
2023-08-19 09:47:45 +00:00
|
|
|
|
|
|
|
public static styles = [
|
|
|
|
cssManager.defaultStyles,
|
|
|
|
css`
|
|
|
|
:host {
|
|
|
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
2023-08-19 16:56:32 +00:00
|
|
|
user-select: none;
|
2023-08-19 09:47:45 +00:00
|
|
|
}
|
2024-01-22 16:29:53 +00:00
|
|
|
.loginContainer, .slotContainer {
|
2023-09-02 12:05:33 +00:00
|
|
|
position: absolute;
|
2023-08-19 09:47:45 +00:00
|
|
|
display: flex;
|
|
|
|
justify-content: center; /* aligns horizontally */
|
|
|
|
align-items: center; /* aligns vertically */
|
2023-09-02 12:05:33 +00:00
|
|
|
width: 100%;
|
2023-08-19 09:47:45 +00:00
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
.login {
|
|
|
|
min-width: 320px;
|
|
|
|
min-height: 100px;
|
|
|
|
background: ${cssManager.bdTheme('#eeeeeb', '#111')};
|
|
|
|
box-shadow: ${cssManager.bdTheme('0px 1px 4px rgba(0,0,0,0.3)', 'none')};
|
2024-01-10 04:11:55 +00:00
|
|
|
border-radius: 8px;
|
2023-08-19 09:47:45 +00:00
|
|
|
padding: 24px;
|
2023-09-02 12:05:33 +00:00
|
|
|
transition: opacity 0.3s, transform 0.3s;
|
2023-08-19 09:47:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.header {
|
|
|
|
text-align: center;
|
|
|
|
}
|
2023-09-02 12:05:33 +00:00
|
|
|
.slotContainer {
|
|
|
|
opacity:0;
|
|
|
|
transition: opacity 0.3s, transform 0.3s;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
2023-08-19 09:47:45 +00:00
|
|
|
`,
|
|
|
|
];
|
|
|
|
|
|
|
|
public render(): TemplateResult {
|
|
|
|
return html`
|
|
|
|
<div class="loginContainer">
|
|
|
|
<div class="login">
|
|
|
|
<dees-form>
|
2023-09-12 23:37:02 +00:00
|
|
|
<div class="header">Login to ${this.name}</div>
|
2023-08-28 07:49:51 +00:00
|
|
|
<dees-input-text key="username" label="username" required></dees-input-text>
|
|
|
|
<dees-input-text key="password" label="password" isPasswordBool required></dees-input-text>
|
2023-08-19 16:56:32 +00:00
|
|
|
<dees-form-submit disabled>login</dees-form-submit>
|
2023-08-19 09:47:45 +00:00
|
|
|
</dees-form>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-02 12:05:33 +00:00
|
|
|
<div class="slotContainer">
|
|
|
|
<slot></slot>
|
|
|
|
</div>
|
2023-08-19 09:47:45 +00:00
|
|
|
`;
|
|
|
|
}
|
2023-08-19 16:56:32 +00:00
|
|
|
|
|
|
|
public async firstUpdated(_changedProperties): Promise<void> {
|
|
|
|
const domtools = await this.domtoolsPromise;
|
|
|
|
super.firstUpdated(_changedProperties);
|
|
|
|
const form = this.shadowRoot.querySelector('dees-form');
|
|
|
|
await form.readyDeferred.promise;
|
|
|
|
const username = this.shadowRoot.querySelector('dees-input-text[label="username"]');
|
|
|
|
const password = this.shadowRoot.querySelector('dees-input-text[label="password"]');
|
|
|
|
const submit = this.shadowRoot.querySelector('dees-form-submit');
|
|
|
|
form.addEventListener('formData', (event: CustomEvent) => {
|
|
|
|
this.dispatchEvent(new CustomEvent('login', { detail: event.detail }));
|
2023-09-02 12:05:33 +00:00
|
|
|
// this.switchToSlottedContent();
|
2023-08-19 16:56:32 +00:00
|
|
|
});
|
|
|
|
}
|
2023-09-02 12:05:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* allows switching to slotted content
|
|
|
|
*/
|
|
|
|
public async switchToSlottedContent() {
|
|
|
|
const domtools = await this.domtoolsPromise;
|
|
|
|
const loginDiv: HTMLDivElement = this.shadowRoot.querySelector('.login');
|
|
|
|
const loginContainerDiv: HTMLDivElement = this.shadowRoot.querySelector('.loginContainer');
|
|
|
|
const slotContainerDiv: HTMLDivElement = this.shadowRoot.querySelector('.slotContainer');
|
|
|
|
loginDiv.style.opacity = '0';
|
|
|
|
loginDiv.style.transform = 'translateY(20px)';
|
|
|
|
loginContainerDiv.style.pointerEvents = 'none';
|
|
|
|
slotContainerDiv.style.transform = 'translateY(20px)';
|
|
|
|
await domtools.convenience.smartdelay.delayFor(300);
|
|
|
|
slotContainerDiv.style.opacity = '1';
|
|
|
|
slotContainerDiv.style.transform = 'translateY(0px)';
|
|
|
|
await domtools.convenience.smartdelay.delayFor(300);
|
|
|
|
slotContainerDiv.style.pointerEvents = 'all';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-08-19 09:47:45 +00:00
|
|
|
}
|