Skip to content

Commit

Permalink
feat(a11y): add aria-label attribute to payment card graphics for Pay…
Browse files Browse the repository at this point in the history
…ment Details cards
  • Loading branch information
ulates-sap committed Oct 16, 2024
1 parent 4f60be3 commit 930739c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
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 @@ export class PaymentMethodsComponent implements OnInit {
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 @@ export class PaymentMethodsComponent implements OnInit {

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

0 comments on commit 930739c

Please sign in to comment.