1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01: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:
Nick Krantz 2024-10-23 10:23:51 -05:00 committed by GitHub
parent dfa7509c8e
commit c4fcd53ad2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 117 additions and 18 deletions

View File

@ -107,6 +107,9 @@
"copyPassword": { "copyPassword": {
"message": "Copy password" "message": "Copy password"
}, },
"copyPassphrase": {
"message": "Copy passphrase"
},
"copyNote": { "copyNote": {
"message": "Copy note" "message": "Copy note"
}, },
@ -407,6 +410,9 @@
"generatePassword": { "generatePassword": {
"message": "Generate password" "message": "Generate password"
}, },
"generatePassphrase": {
"message": "Generate passphrase"
},
"regeneratePassword": { "regeneratePassword": {
"message": "Regenerate password" "message": "Regenerate password"
}, },

View File

@ -259,6 +259,9 @@
"generatePassword": { "generatePassword": {
"message": "Generate password" "message": "Generate password"
}, },
"generatePassphrase": {
"message": "Generate passphrase"
},
"type": { "type": {
"message": "Type" "message": "Type"
}, },
@ -394,6 +397,10 @@
"copyPassword": { "copyPassword": {
"message": "Copy password" "message": "Copy password"
}, },
"copyPassphrase": {
"message": "Copy passphrase",
"description": "Copy passphrase to clipboard"
},
"copyUri": { "copyUri": {
"message": "Copy URI" "message": "Copy URI"
}, },

View File

@ -405,6 +405,9 @@
"generatePassword": { "generatePassword": {
"message": "Generate password" "message": "Generate password"
}, },
"generatePassphrase": {
"message": "Generate passphrase"
},
"checkPassword": { "checkPassword": {
"message": "Check if password has been exposed." "message": "Check if password has been exposed."
}, },
@ -663,6 +666,10 @@
"message": "Copy password", "message": "Copy password",
"description": "Copy password to clipboard" "description": "Copy password to clipboard"
}, },
"copyPassphrase": {
"message": "Copy passphrase",
"description": "Copy passphrase to clipboard"
},
"passwordCopied": { "passwordCopied": {
"message": "Password copied" "message": "Password copied"
}, },

View File

@ -16,18 +16,21 @@
<bit-color-password class="tw-font-mono" [password]="value$ | async"></bit-color-password> <bit-color-password class="tw-font-mono" [password]="value$ | async"></bit-color-password>
</div> </div>
<div class="tw-flex tw-items-center tw-space-x-1"> <div class="tw-flex tw-items-center tw-space-x-1">
<button type="button" bitIconButton="bwi-generate" buttonType="main" (click)="generate$.next()"> <button
{{ "generatePassword" | i18n }} type="button"
</button> bitIconButton="bwi-generate"
buttonType="main"
(click)="generate$.next()"
[appA11yTitle]="credentialTypeGenerateLabel$ | async"
></button>
<button <button
type="button" type="button"
bitIconButton="bwi-clone" bitIconButton="bwi-clone"
buttonType="main" buttonType="main"
showToast showToast
[appA11yTitle]="credentialTypeCopyLabel$ | async"
[appCopyClick]="value$ | async" [appCopyClick]="value$ | async"
> ></button>
{{ "copyPassword" | i18n }}
</button>
</div> </div>
</bit-card> </bit-card>
<tools-password-settings <tools-password-settings

View File

@ -63,6 +63,44 @@ export class CredentialGeneratorComponent implements OnInit, OnDestroy {
nav: null, 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) { protected onRootChanged(nav: RootNavValue) {
// prevent subscription cycle // prevent subscription cycle
if (this.root$.value.nav !== nav) { if (this.root$.value.nav !== nav) {

View File

@ -14,18 +14,21 @@
<bit-color-password class="tw-font-mono" [password]="value$ | async"></bit-color-password> <bit-color-password class="tw-font-mono" [password]="value$ | async"></bit-color-password>
</div> </div>
<div class="tw-flex tw-items-center tw-space-x-1"> <div class="tw-flex tw-items-center tw-space-x-1">
<button type="button" bitIconButton="bwi-generate" buttonType="main" (click)="generate$.next()"> <button
{{ "generatePassword" | i18n }} type="button"
</button> bitIconButton="bwi-generate"
buttonType="main"
(click)="generate$.next()"
[appA11yTitle]="credentialTypeGenerateLabel$ | async"
></button>
<button <button
type="button" type="button"
bitIconButton="bwi-clone" bitIconButton="bwi-clone"
buttonType="main" buttonType="main"
showToast showToast
[appA11yTitle]="credentialTypeCopyLabel$ | async"
[appCopyClick]="value$ | async" [appCopyClick]="value$ | async"
> ></button>
{{ "copyPassword" | i18n }}
</button>
</div> </div>
</bit-card> </bit-card>
<tools-password-settings <tools-password-settings

View File

@ -52,6 +52,36 @@ export class PasswordGeneratorComponent implements OnInit, OnDestroy {
/** tracks the currently selected credential type */ /** tracks the currently selected credential type */
protected credentialType$ = new BehaviorSubject<PasswordAlgorithm>(null); 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. */ /** Emits the last generated value. */
protected readonly value$ = new BehaviorSubject<string>(""); protected readonly value$ = new BehaviorSubject<string>("");

View File

@ -3,18 +3,23 @@
<bit-color-password class="tw-font-mono" [password]="value$ | async"></bit-color-password> <bit-color-password class="tw-font-mono" [password]="value$ | async"></bit-color-password>
</div> </div>
<div class="tw-flex tw-items-center tw-space-x-1"> <div class="tw-flex tw-items-center tw-space-x-1">
<button type="button" bitIconButton="bwi-generate" buttonType="main" (click)="generate$.next()"> <!-- FIXME: Move appA11yTitle translation to `AlgorithmInfo` within the `CredentialGeneratorService`. -->
{{ "generatePassword" | i18n }} <button
</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 <button
type="button" type="button"
bitIconButton="bwi-clone" bitIconButton="bwi-clone"
buttonType="main" buttonType="main"
showToast showToast
[appA11yTitle]="'copyUsername' | i18n"
[appCopyClick]="value$ | async" [appCopyClick]="value$ | async"
> ></button>
{{ "copyPassword" | i18n }}
</button>
</div> </div>
</bit-card> </bit-card>
<bit-section [disableMargin]="disableMargin"> <bit-section [disableMargin]="disableMargin">