Skip to content

Commit

Permalink
Fall back to ccd logo
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenbf committed Nov 28, 2024
1 parent 589d50e commit 7642342
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@
}

svg, img {
width: rem(16px);
height: rem(16px);
width: rem(22px);
height: rem(22px);
background-color: $color-white;
padding: rem(2px);
border-radius: rem(4px);

object-position: center;
object-fit: contain;

path {
fill: $color-grey-3;
}
}

&__top {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import {
VerifiableCredentialStatus,
} from '@shared/storage/types';

import Img from '@popup/shared/Img';
import {
defaultFormatAttribute,
useCredentialLocalization,
useCredentialMetadata,
useCredentialSchema,
useCredentialStatus,
} from '../utils/verifiable-credentials';
import Img from '@popup/shared/Img';

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

// TODO:
// - Use the icon from the issuer if available
export default function Web3IdCard({ credential, ...viewProps }: Props) {
const { t } = useTranslation('x', { keyPrefix: 'sharedX.web3IdCard.warning' });
const status = useCredentialStatus(credential);
Expand Down Expand Up @@ -184,6 +182,7 @@ export default function Web3IdCard({ credential, ...viewProps }: Props) {
title={metadata.title}
status={status}
warning={warning}
logo={metadata.logo}
{...viewProps}
/>
);
Expand Down
7 changes: 5 additions & 2 deletions packages/browser-wallet/src/popup/shared/Img.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type WithDefaultsProps = BaseProps & {
type NoDefaultsProps = BaseProps & {
withDefaults?: false;
loadingImage?: string;
failedImage?: string;
failedImage?: string | JSX.Element;
};

type Props = WithDefaultsProps | NoDefaultsProps;
Expand Down Expand Up @@ -49,7 +49,10 @@ export default function Img({ src, alt, className, ...props }: Props) {
}}
onError={handleError}
/>
{shouldHide && <img className={className} src={failed ? failedImage : loadingImage} alt={alt} />}
{shouldHide && failed && typeof failedImage !== 'string' && failedImage !== undefined && failedImage}
{shouldHide && (typeof failedImage === 'string' || failedImage === undefined || !failed) && (
<img className={className} src={failed ? (failedImage as string) : loadingImage} alt={alt} />
)}
</>
);
}

0 comments on commit 7642342

Please sign in to comment.