Skip to content

Commit 7642342

Browse files
committed
Fall back to ccd logo
1 parent 589d50e commit 7642342

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

packages/browser-wallet/src/popup/popupX/shared/Web3IdCard/Web3IdCard.scss

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,18 @@
2727
}
2828

2929
svg, img {
30-
width: rem(16px);
31-
height: rem(16px);
30+
width: rem(22px);
31+
height: rem(22px);
32+
background-color: $color-white;
33+
padding: rem(2px);
34+
border-radius: rem(4px);
3235

3336
object-position: center;
3437
object-fit: contain;
38+
39+
path {
40+
fill: $color-grey-3;
41+
}
3542
}
3643

3744
&__top {

packages/browser-wallet/src/popup/popupX/shared/Web3IdCard/Web3IdCard.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import {
1414
VerifiableCredentialStatus,
1515
} from '@shared/storage/types';
1616

17+
import Img from '@popup/shared/Img';
1718
import {
1819
defaultFormatAttribute,
1920
useCredentialLocalization,
2021
useCredentialMetadata,
2122
useCredentialSchema,
2223
useCredentialStatus,
2324
} from '../utils/verifiable-credentials';
24-
import Img from '@popup/shared/Img';
2525

2626
/**
2727
* Component for displaying the status of a verifiable credential.
@@ -75,9 +75,9 @@ export function Web3IdCardView({ status, title, attributes, className, warning,
7575
<Card className={clsx('web3-id-card-x', className)}>
7676
<Card.Row>
7777
<div className="web3-id-card-x__top">
78-
<div className="flex align-items-center justify-space-between">
79-
<div className="flex align-items-center">
80-
{logo !== undefined ? <Img src={logo.url} withDefaults /> : <ConcordiumLogo />}
78+
<div className="flex align-center justify-space-between">
79+
<div className="flex align-center">
80+
{logo !== undefined ? <Img src={logo.url} /> : <ConcordiumLogo />}
8181
<Text.MainMedium>{title}</Text.MainMedium>
8282
</div>
8383
<Status status={status} />
@@ -149,8 +149,6 @@ type Props = Pick<ViewProps, 'className'> & {
149149
credential: VerifiableCredential;
150150
};
151151

152-
// TODO:
153-
// - Use the icon from the issuer if available
154152
export default function Web3IdCard({ credential, ...viewProps }: Props) {
155153
const { t } = useTranslation('x', { keyPrefix: 'sharedX.web3IdCard.warning' });
156154
const status = useCredentialStatus(credential);
@@ -184,6 +182,7 @@ export default function Web3IdCard({ credential, ...viewProps }: Props) {
184182
title={metadata.title}
185183
status={status}
186184
warning={warning}
185+
logo={metadata.logo}
187186
{...viewProps}
188187
/>
189188
);

packages/browser-wallet/src/popup/shared/Img.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type WithDefaultsProps = BaseProps & {
1717
type NoDefaultsProps = BaseProps & {
1818
withDefaults?: false;
1919
loadingImage?: string;
20-
failedImage?: string;
20+
failedImage?: string | JSX.Element;
2121
};
2222

2323
type Props = WithDefaultsProps | NoDefaultsProps;
@@ -49,7 +49,10 @@ export default function Img({ src, alt, className, ...props }: Props) {
4949
}}
5050
onError={handleError}
5151
/>
52-
{shouldHide && <img className={className} src={failed ? failedImage : loadingImage} alt={alt} />}
52+
{shouldHide && failed && typeof failedImage !== 'string' && failedImage !== undefined && failedImage}
53+
{shouldHide && (typeof failedImage === 'string' || failedImage === undefined || !failed) && (
54+
<img className={className} src={failed ? (failedImage as string) : loadingImage} alt={alt} />
55+
)}
5356
</>
5457
);
5558
}

0 commit comments

Comments
 (0)