Add particles to login, move forgot password link (#18868)

This commit is contained in:
Bram Kragten 2023-12-04 11:34:42 +01:00 committed by GitHub
parent b273b31b03
commit 7e74502ba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 66 deletions

View File

@ -279,6 +279,10 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
); );
} }
if (window.innerWidth > 450) {
import("../resources/particles");
}
// If we are logging into the instance that is hosting this auth form // If we are logging into the instance that is hosting this auth form
// we will register the service worker to start preloading. // we will register the service worker to start preloading.
if (url.host === location.host) { if (url.host === location.host) {

View File

@ -154,6 +154,10 @@ export class HaLocalAuthFlow extends LitElement {
ha-button { ha-button {
--mdc-typography-button-text-transform: none; --mdc-typography-button-text-transform: none;
} }
.forgot-password-container {
text-align: right;
padding: 8px 0 16px 0;
}
a.forgot-password { a.forgot-password {
color: var(--primary-color); color: var(--primary-color);
text-decoration: none; text-decoration: none;
@ -177,7 +181,7 @@ export class HaLocalAuthFlow extends LitElement {
</style> </style>
${this._error ${this._error
? html`<ha-alert alert-type="error">${this._error}</ha-alert>` ? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
: ""} : nothing}
${this._step ${this._step
? html`<ha-auth-flow ? html`<ha-auth-flow
.clientId=${this.clientId} .clientId=${this.clientId}
@ -188,7 +192,8 @@ export class HaLocalAuthFlow extends LitElement {
.localize=${this.localize} .localize=${this.localize}
></ha-auth-flow>` ></ha-auth-flow>`
: this._selectedUser : this._selectedUser
? html`<div class="login-form"><div class="person"> ? html`<div class="login-form">
<div class="person">
<ha-person-badge <ha-person-badge
.person=${this._persons[this._selectedUser]} .person=${this._persons[this._selectedUser]}
></ha-person-badge> ></ha-person-badge>
@ -199,10 +204,12 @@ export class HaLocalAuthFlow extends LitElement {
type="hidden" type="hidden"
name="username" name="username"
autocomplete="username" autocomplete="username"
readonly
.value=${this.authProvider.users[this._selectedUser]} .value=${this.authProvider.users[this._selectedUser]}
/> />
<ha-auth-textfield <ha-auth-textfield
.type=${this._unmaskedPassword ? "text" : "password"} .type=${this._unmaskedPassword ? "text" : "password"}
autocomplete="current-password"
id="password" id="password"
name="password" name="password"
.label=${this.localize( .label=${this.localize(
@ -210,23 +217,33 @@ export class HaLocalAuthFlow extends LitElement {
)} )}
required required
autoValidate autoValidate
autocomplete
iconTrailing iconTrailing
validationMessage="Required" validationMessage="Required"
> >
<ha-icon-button <ha-icon-button
toggles toggles
.label=${ .label=${this.localize(
this.localize(
this._unmaskedPassword this._unmaskedPassword
? "ui.panel.page-authorize.form.hide_password" ? "ui.panel.page-authorize.form.hide_password"
: "ui.panel.page-authorize.form.show_password" : "ui.panel.page-authorize.form.show_password"
) || (this._unmaskedPassword ? "Hide password" : "Show password") ) ||
} (this._unmaskedPassword
? "Hide password"
: "Show password")}
@click=${this._toggleUnmaskedPassword} @click=${this._toggleUnmaskedPassword}
.path=${this._unmaskedPassword ? mdiEyeOff : mdiEye} .path=${this._unmaskedPassword ? mdiEyeOff : mdiEye}
></ha-icon-button> ></ha-icon-button>
</ha-auth-textfield> </ha-auth-textfield>
<div class="forgot-password-container">
<a
class="forgot-password"
href="https://www.home-assistant.io/docs/locked_out/#forgot-password"
target="_blank"
rel="noreferrer noopener"
>${this.localize(
"ui.panel.page-authorize.forgot_password"
)}</a
>
</div> </div>
<div class="action space-between"> <div class="action space-between">
<mwc-button <mwc-button
@ -243,17 +260,8 @@ export class HaLocalAuthFlow extends LitElement {
${this.localize("ui.panel.page-authorize.form.next")} ${this.localize("ui.panel.page-authorize.form.next")}
</mwc-button> </mwc-button>
</div> </div>
<div class="action"> </form>
<a class="forgot-password" </div>`
href="https://www.home-assistant.io/docs/locked_out/#forgot-password"
target="_blank"
rel="noreferrer noopener"
>${this.localize(
"ui.panel.page-authorize.forgot_password"
)}</a
>
</div>
</form>`
: html`<h1> : html`<h1>
${this.localize("ui.panel.page-authorize.welcome_home")} ${this.localize("ui.panel.page-authorize.welcome_home")}
</h1> </h1>

View File

@ -218,7 +218,7 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
this._handleProgress(ev) this._handleProgress(ev)
); );
if (window.innerWidth > 450) { if (window.innerWidth > 450) {
import("./particles"); import("../resources/particles");
} }
makeDialogManager(this, this.shadowRoot!); makeDialogManager(this, this.shadowRoot!);
import("../components/ha-language-picker"); import("../components/ha-language-picker");

View File

@ -1,6 +1,6 @@
import { tsParticles } from "tsparticles-engine"; import { tsParticles } from "tsparticles-engine";
import { loadLinksPreset } from "tsparticles-preset-links"; import { loadLinksPreset } from "tsparticles-preset-links";
import { DEFAULT_PRIMARY_COLOR } from "../resources/styles-data"; import { DEFAULT_PRIMARY_COLOR } from "./styles-data";
loadLinksPreset(tsParticles).then(() => { loadLinksPreset(tsParticles).then(() => {
tsParticles.load("particles", { tsParticles.load("particles", {