-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dda7577
commit e19a528
Showing
34 changed files
with
1,541 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
browser/resources/settings/getting_started_page/brave_account_browser_proxy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
import { sendWithPromise } from '//resources/js/cr.js' | ||
|
||
export interface BraveAccountBrowserProxy { | ||
getPasswordStrength(password: string): Promise<number> | ||
} | ||
|
||
export class BraveAccountBrowserProxyImpl implements BraveAccountBrowserProxy { | ||
getPasswordStrength (password: string) { | ||
return sendWithPromise('getPasswordStrength', password) | ||
} | ||
|
||
static getInstance() { | ||
return instance || (instance = new BraveAccountBrowserProxyImpl()) | ||
} | ||
} | ||
|
||
let instance: BraveAccountBrowserProxy | null = null |
26 changes: 26 additions & 0 deletions
26
browser/resources/settings/getting_started_page/brave_account_common.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
/* #css_wrapper_metadata_start | ||
* #type=style-lit | ||
* #css_wrapper_metadata_end */ | ||
|
||
.label { | ||
color: var(--leo-color-text-primary); | ||
font: var(--leo-font-small-semibold); | ||
margin: 0px 0px 0px var(--leo-spacing-s); | ||
} | ||
|
||
.label.error { | ||
color: var(--leo-color-systemfeedback-error-text); | ||
} | ||
|
||
leo-input { | ||
--leo-control-border-color: var(--leo-color-divider-strong); | ||
} | ||
|
||
leo-input:not(:focus):has(> .error) { | ||
--leo-control-border-color: var(--leo-color-systemfeedback-error-icon); | ||
} |
17 changes: 17 additions & 0 deletions
17
browser/resources/settings/getting_started_page/brave_account_common.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
export function onEyeIconClicked(event: Event) { | ||
event.preventDefault() | ||
let type = 'password' | ||
const target = event.target as Element | ||
target.setAttribute('name', | ||
target.getAttribute('name') === 'eye-off' | ||
? (type = 'text', 'eye-on') | ||
: 'eye-off') | ||
target.parentElement!.setAttribute('type', type) | ||
} | ||
|
||
export const emailRegexp = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/ |
68 changes: 68 additions & 0 deletions
68
browser/resources/settings/getting_started_page/brave_account_create_dialog.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
/* #css_wrapper_metadata_start | ||
* #type=style-lit | ||
* #scheme=relative | ||
* #import=./brave_account_common.css.js | ||
* #include=brave-account-common | ||
* #css_wrapper_metadata_end */ | ||
|
||
.dropdown { | ||
height: var(--height); | ||
margin: calc(-1 * var(--height)) var(--leo-spacing-s) 0px var(--leo-spacing-s); | ||
position: relative; | ||
transition: all 750ms; | ||
z-index: -1; | ||
} | ||
|
||
.dropdown.visible { | ||
margin-top: var(--leo-spacing-s); | ||
} | ||
|
||
#brave-alias-dropdown { | ||
--height: 36px; | ||
--leo-icon-size: var(--leo-icon-xs); | ||
display: flex; | ||
font: var(--leo-font-small-regular); | ||
gap: var(--leo-spacing-s); | ||
} | ||
|
||
#password-dropdown { | ||
--height: 18px; | ||
display: flex; | ||
} | ||
|
||
#password-confirmation-dropdown { | ||
--height: 18px; | ||
--leo-icon-size: var(--leo-icon-xs); | ||
align-items: center; | ||
display: flex; | ||
font: var(--leo-font-small-regular); | ||
gap: var(--leo-spacing-s); | ||
} | ||
|
||
leo-icon[name=check-circle-filled] { | ||
--leo-icon-color: var(--leo-color-text-interactive); | ||
} | ||
|
||
leo-icon[name=check-circle-filled] + div { | ||
color: var(--leo-color-text-interactive); | ||
} | ||
|
||
leo-icon[name=warning-triangle-filled] { | ||
--leo-icon-color: var(--leo-color-systemfeedback-error-icon); | ||
} | ||
|
||
leo-icon[name=warning-triangle-filled] + div { | ||
color: var(--leo-color-systemfeedback-error-text); | ||
} | ||
|
||
leo-checkbox a { | ||
color: var(--leo-color-text-interactive); | ||
font: var(--leo-font-default-link); | ||
text-decoration-skip-ink: none; | ||
text-underline-offset: 2.8px; | ||
} |
98 changes: 98 additions & 0 deletions
98
browser/resources/settings/getting_started_page/brave_account_create_dialog.html.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
import { html } from '//resources/lit/v3_0/lit.rollup.js' | ||
|
||
import { onEyeIconClicked } from './brave_account_common.js' | ||
import { SettingsBraveAccountCreateDialogElement } from './brave_account_create_dialog.js' | ||
|
||
export function getHtml(this: SettingsBraveAccountCreateDialogElement) { | ||
return html`<!--_html_template_start_--> | ||
<settings-brave-account-dialog | ||
dialog-description="$i18n{braveAccountCreateDialogDescription}" | ||
dialog-title="$i18n{braveAccountCreateDialogTitle}" | ||
show-back-button | ||
> | ||
<div slot="inputs"> | ||
<leo-input placeholder="$i18n{braveAccountEmailInputPlaceholder}" | ||
showErrors | ||
@input=${this.onEmailInput}> | ||
<div class="label ${this.email.length !== 0 && !this.isEmailValid | ||
|| this.isEmailValid && this.isEmailBraveAlias ? | ||
'error' : ''}"> | ||
$i18n{braveAccountEmailInputLabel} | ||
</div> | ||
<div class="dropdown ${this.isEmailValid && this.isEmailBraveAlias ? | ||
'visible' : ''}" | ||
id="brave-alias-dropdown" | ||
slot="errors"> | ||
<leo-icon name="warning-triangle-filled"></leo-icon> | ||
<div>$i18n{braveAccountEmailInputErrorMessage}</div> | ||
</div> | ||
</leo-input> | ||
<leo-input placeholder="$i18n{braveAccountAccountNameInputPlaceholder}" | ||
@input=${this.onAccountNameInput}> | ||
<div class="label">$i18n{braveAccountAccountNameInputLabel}</div> | ||
</leo-input> | ||
<leo-input placeholder="$i18n{braveAccountPasswordInputPlaceholder}" | ||
showErrors | ||
type="password" | ||
@input=${this.onPasswordInput}> | ||
<div class="label">$i18n{braveAccountCreatePasswordInputLabel}</div> | ||
<leo-icon name="eye-off" | ||
slot="right-icon" | ||
@click=${onEyeIconClicked}> | ||
</leo-icon> | ||
<div slot="errors" class="dropdown ${this.passwordStrength !== 0 ? | ||
'visible' : ''}" | ||
id="password-dropdown"> | ||
<password-strength-meter strength=${this.passwordStrength}> | ||
</password-strength-meter> | ||
</div> | ||
</leo-input> | ||
<leo-input placeholder="$i18n{braveAccountConfirmPasswordInputPlaceholder}" | ||
showErrors | ||
type="password" | ||
@input=${this.onConfirmPasswordInput}> | ||
<div class="label ${this.passwordConfirmation.length !== 0 | ||
&& this.passwordConfirmation !== this.password ? | ||
'error' : ''}"> | ||
$i18n{braveAccountConfirmPasswordInputLabel} | ||
</div> | ||
<leo-icon name="eye-off" | ||
slot="right-icon" | ||
@click=${onEyeIconClicked}> | ||
</leo-icon> | ||
<div class="dropdown ${this.passwordConfirmation.length !== 0 ? | ||
'visible' : ''}" | ||
id="password-confirmation-dropdown" | ||
slot="errors"> | ||
<leo-icon name=${this.getIconName()}></leo-icon> | ||
<div> | ||
${this.icon === 'check-circle-filled' | ||
? html`$i18n{braveAccountConfirmPasswordInputSuccessMessage}` | ||
: html`$i18n{braveAccountConfirmPasswordInputErrorMessage}` | ||
} | ||
</div> | ||
</div> | ||
</leo-input> | ||
<leo-checkbox @change=${this.onCheckboxChanged}> | ||
<div>$i18nRaw{braveAccountConsentCheckboxLabel}</div> | ||
</leo-checkbox> | ||
</div> | ||
<div slot="buttons"> | ||
<leo-button ?isDisabled=${!this.isEmailValid | ||
|| this.isEmailValid && this.isEmailBraveAlias | ||
|| !this.isAccountNameValid | ||
|| this.passwordStrength !== 100 | ||
|| this.passwordConfirmation !== this.password | ||
|| !this.isCheckboxChecked} | ||
@click=${() => this.fire('create-account-button-clicked')}> | ||
$i18n{braveAccountCreateAccountButtonLabel} | ||
</leo-button> | ||
</div> | ||
</settings-brave-account-dialog> | ||
<!--_html_template_end_-->` | ||
} |
Oops, something went wrong.