Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(a11y): add aria-label attribute to payment card graphics for Payment Details cards #19404

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion projects/assets/src/translations/en/payment.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
"defaultPaymentLabel": "Default payment method",
"additionalPaymentLabel": "Additional payment method {{ number }}",
"selected": "Selected",
"deletePaymentSuccess": "Payment method deleted successfully"
"deletePaymentSuccess": "Payment method deleted successfully",
"visa": "Visa Card",
"master": "Master Card",

Check warning on line 45 in projects/assets/src/translations/en/payment.json

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/\b(?!masterdata|masterdata\w+\b)master/gi

Check warning on line 45 in projects/assets/src/translations/en/payment.json

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `Master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/\b(?!masterdata|masterdata\w+\b)master/gi
"dinersClub": "Diners Club Card",
"amex": "American Express Card",
"credit": "Credit Card"
},
"paymentTypes": {
"title": "Payment method",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
actions,
deleteMsg: textDeleteConfirmation,
img: this.getCardIcon(cardType?.code ?? ''),
imgLabel: this.getCardIconLabel(cardType?.code),
label: defaultPayment
? 'paymentCard.defaultPaymentLabel'
: 'paymentCard.additionalPaymentLabel',
Expand Down Expand Up @@ -140,4 +141,21 @@

return ccIcon;
}

getCardIconLabel(code: string | undefined): string {
let ccIconLabel: string;
if (code === 'visa') {
ccIconLabel = 'paymentCard.visa';
} else if (code === 'master' || code === 'mastercard_eurocard') {

Check warning on line 149 in projects/storefrontlib/cms-components/myaccount/payment-methods/payment-methods.component.ts

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/\b(?!masterdata|masterdata\w+\b)master/gi

Check warning on line 149 in projects/storefrontlib/cms-components/myaccount/payment-methods/payment-methods.component.ts

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/\b(?!masterdata|masterdata\w+\b)master/gi
ccIconLabel = 'paymentCard.master';

Check warning on line 150 in projects/storefrontlib/cms-components/myaccount/payment-methods/payment-methods.component.ts

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/\b(?!masterdata|masterdata\w+\b)master/gi
} else if (code === 'diners') {
ccIconLabel = 'paymentCard.dinersClub';
} else if (code === 'amex') {
ccIconLabel = 'paymentCard.amex';
} else {
ccIconLabel = 'paymentCard.credit';
}

return ccIconLabel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@
<ng-content select="[label_container_bottom]"></ng-content>
</div>
<!-- Image -->
<div *ngIf="content.img" class="cx-card-img-container">
<div
*ngIf="content.img"
class="cx-card-img-container"
[attr.aria-label]="
content.imgLabel ?? 'paymentCard.credit' | cxTranslate
"
role="img"
>
<cx-icon [type]="content.img"></cx-icon>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface Card {
text?: Array<string>;
paragraphs?: Array<{ title?: string; text?: Array<string> }>;
img?: string;
imgLabel?: string;
actions?: Array<CardAction | CardLinkAction>;
deleteMsg?: string;
label?: string;
Expand Down
Loading