mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
[PM-13776] Generator Icon Button labels (#11623)
* update aria labels for generate and copy buttons within the generator components - Using the `appA11yTitle` across all icon buttons - Updated all labels to be targeted towards the credential type rather than just "password" * add copy/generate passphrase translations to desktop * add fixme comments for translations * remove reference to JIRA ticket
This commit is contained in:
@@ -16,18 +16,21 @@
|
||||
<bit-color-password class="tw-font-mono" [password]="value$ | async"></bit-color-password>
|
||||
</div>
|
||||
<div class="tw-flex tw-items-center tw-space-x-1">
|
||||
<button type="button" bitIconButton="bwi-generate" buttonType="main" (click)="generate$.next()">
|
||||
{{ "generatePassword" | i18n }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
bitIconButton="bwi-generate"
|
||||
buttonType="main"
|
||||
(click)="generate$.next()"
|
||||
[appA11yTitle]="credentialTypeGenerateLabel$ | async"
|
||||
></button>
|
||||
<button
|
||||
type="button"
|
||||
bitIconButton="bwi-clone"
|
||||
buttonType="main"
|
||||
showToast
|
||||
[appA11yTitle]="credentialTypeCopyLabel$ | async"
|
||||
[appCopyClick]="value$ | async"
|
||||
>
|
||||
{{ "copyPassword" | i18n }}
|
||||
</button>
|
||||
></button>
|
||||
</div>
|
||||
</bit-card>
|
||||
<tools-password-settings
|
||||
|
||||
@@ -63,6 +63,44 @@ export class CredentialGeneratorComponent implements OnInit, OnDestroy {
|
||||
nav: null,
|
||||
});
|
||||
|
||||
/**
|
||||
* Emits the copy button aria-label respective of the selected credential type
|
||||
*
|
||||
* FIXME: Move label and logic to `AlgorithmInfo` within the `CredentialGeneratorService`.
|
||||
*/
|
||||
protected credentialTypeCopyLabel$ = this.root$.pipe(
|
||||
map(({ nav }) => {
|
||||
if (nav === "password") {
|
||||
return this.i18nService.t("copyPassword");
|
||||
}
|
||||
|
||||
if (nav === "passphrase") {
|
||||
return this.i18nService.t("copyPassphrase");
|
||||
}
|
||||
|
||||
return this.i18nService.t("copyUsername");
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Emits the generate button aria-label respective of the selected credential type
|
||||
*
|
||||
* FIXME: Move label and logic to `AlgorithmInfo` within the `CredentialGeneratorService`.
|
||||
*/
|
||||
protected credentialTypeGenerateLabel$ = this.root$.pipe(
|
||||
map(({ nav }) => {
|
||||
if (nav === "password") {
|
||||
return this.i18nService.t("generatePassword");
|
||||
}
|
||||
|
||||
if (nav === "passphrase") {
|
||||
return this.i18nService.t("generatePassphrase");
|
||||
}
|
||||
|
||||
return this.i18nService.t("generateUsername");
|
||||
}),
|
||||
);
|
||||
|
||||
protected onRootChanged(nav: RootNavValue) {
|
||||
// prevent subscription cycle
|
||||
if (this.root$.value.nav !== nav) {
|
||||
|
||||
@@ -14,18 +14,21 @@
|
||||
<bit-color-password class="tw-font-mono" [password]="value$ | async"></bit-color-password>
|
||||
</div>
|
||||
<div class="tw-flex tw-items-center tw-space-x-1">
|
||||
<button type="button" bitIconButton="bwi-generate" buttonType="main" (click)="generate$.next()">
|
||||
{{ "generatePassword" | i18n }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
bitIconButton="bwi-generate"
|
||||
buttonType="main"
|
||||
(click)="generate$.next()"
|
||||
[appA11yTitle]="credentialTypeGenerateLabel$ | async"
|
||||
></button>
|
||||
<button
|
||||
type="button"
|
||||
bitIconButton="bwi-clone"
|
||||
buttonType="main"
|
||||
showToast
|
||||
[appA11yTitle]="credentialTypeCopyLabel$ | async"
|
||||
[appCopyClick]="value$ | async"
|
||||
>
|
||||
{{ "copyPassword" | i18n }}
|
||||
</button>
|
||||
></button>
|
||||
</div>
|
||||
</bit-card>
|
||||
<tools-password-settings
|
||||
|
||||
@@ -52,6 +52,36 @@ export class PasswordGeneratorComponent implements OnInit, OnDestroy {
|
||||
/** tracks the currently selected credential type */
|
||||
protected credentialType$ = new BehaviorSubject<PasswordAlgorithm>(null);
|
||||
|
||||
/**
|
||||
* Emits the copy button aria-label respective of the selected credential
|
||||
*
|
||||
* FIXME: Move label and logic to `AlgorithmInfo` within the `CredentialGeneratorService`.
|
||||
*/
|
||||
protected credentialTypeCopyLabel$ = this.credentialType$.pipe(
|
||||
map((cred) => {
|
||||
if (cred === "password") {
|
||||
return this.i18nService.t("copyPassword");
|
||||
}
|
||||
|
||||
return this.i18nService.t("copyPassphrase");
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Emits the generate button aria-label respective of the selected credential
|
||||
*
|
||||
* FIXME: Move label and logic to `AlgorithmInfo` within the `CredentialGeneratorService`.
|
||||
*/
|
||||
protected credentialTypeGenerateLabel$ = this.credentialType$.pipe(
|
||||
map((cred) => {
|
||||
if (cred === "password") {
|
||||
return this.i18nService.t("generatePassword");
|
||||
}
|
||||
|
||||
return this.i18nService.t("generatePassphrase");
|
||||
}),
|
||||
);
|
||||
|
||||
/** Emits the last generated value. */
|
||||
protected readonly value$ = new BehaviorSubject<string>("");
|
||||
|
||||
|
||||
@@ -3,18 +3,23 @@
|
||||
<bit-color-password class="tw-font-mono" [password]="value$ | async"></bit-color-password>
|
||||
</div>
|
||||
<div class="tw-flex tw-items-center tw-space-x-1">
|
||||
<button type="button" bitIconButton="bwi-generate" buttonType="main" (click)="generate$.next()">
|
||||
{{ "generatePassword" | i18n }}
|
||||
</button>
|
||||
<!-- FIXME: Move appA11yTitle translation to `AlgorithmInfo` within the `CredentialGeneratorService`. -->
|
||||
<button
|
||||
type="button"
|
||||
bitIconButton="bwi-generate"
|
||||
buttonType="main"
|
||||
(click)="generate$.next()"
|
||||
[appA11yTitle]="'generateUsername' | i18n"
|
||||
></button>
|
||||
<!-- FIXME: Move appA11yTitle translation to `AlgorithmInfo` within the `CredentialGeneratorService`. -->
|
||||
<button
|
||||
type="button"
|
||||
bitIconButton="bwi-clone"
|
||||
buttonType="main"
|
||||
showToast
|
||||
[appA11yTitle]="'copyUsername' | i18n"
|
||||
[appCopyClick]="value$ | async"
|
||||
>
|
||||
{{ "copyPassword" | i18n }}
|
||||
</button>
|
||||
></button>
|
||||
</div>
|
||||
</bit-card>
|
||||
<bit-section [disableMargin]="disableMargin">
|
||||
|
||||
Reference in New Issue
Block a user