1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 15:23:33 +00:00

Select an image to display for credit cards based on the brand. (#537)

Co-authored-by: Hinton <oscar@oscarhinton.com>
This commit is contained in:
Linus Aarnio
2021-12-16 18:41:37 +01:00
committed by GitHub
parent 36b3aea758
commit e9666458c4
18 changed files with 67 additions and 0 deletions

View File

@@ -18,6 +18,21 @@ const IconMap: any = {
"fa-apple": String.fromCharCode(0xf179),
};
/**
* Provides a mapping from supported card brands to
* the filenames of icon that should be present in images/cards folder of clients.
*/
const cardIcons: Record<string, string> = {
Visa: "card-visa",
Mastercard: "card-mastercard",
Amex: "card-amex",
Discover: "card-discover",
"Diners Club": "card-diners-club",
JCB: "card-jcb",
Maestro: "card-maestro",
UnionPay: "card-union-pay",
};
@Component({
selector: "app-vault-icon",
templateUrl: "icon.component.html",
@@ -59,6 +74,7 @@ export class IconComponent implements OnChanges {
break;
case CipherType.Card:
this.icon = "fa-credit-card";
this.setCardIcon();
break;
case CipherType.Identity:
this.icon = "fa-id-card-o";
@@ -102,4 +118,11 @@ export class IconComponent implements OnChanges {
this.image = null;
}
}
private setCardIcon() {
const brand = this.cipher.card.brand;
if (this.imageEnabled && brand in cardIcons) {
this.icon = "credit-card-icon " + cardIcons[brand];
}
}
}