-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #508 from onflow/506-feature-display-the-dapp-imag…
…e-with-the-correct-icon fixed: replace the image when rendering url with a placeholder
- Loading branch information
Showing
6 changed files
with
53 additions
and
40 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/ui/views/Approval/components/EthApproval/EthApprovalComponents/IconWithPlaceholder.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { CardMedia } from '@mui/material'; | ||
import React from 'react'; | ||
|
||
import flowgrey from 'ui/FRWAssets/svg/flow-grey.svg'; | ||
|
||
interface IconWithPlaceholderProps { | ||
imageUrl: string; | ||
width?: string | number; | ||
height?: string | number; | ||
borderRadius?: string | number; | ||
backgroundColor?: string; | ||
} | ||
|
||
const IconWithPlaceholder: React.FC<IconWithPlaceholderProps> = ({ | ||
imageUrl, | ||
width = '60px', | ||
height = '60px', | ||
borderRadius = '12px', | ||
backgroundColor = 'text.secondary', | ||
}) => { | ||
return ( | ||
<CardMedia | ||
component="img" | ||
sx={{ | ||
width, | ||
height, | ||
borderRadius, | ||
backgroundColor, | ||
}} | ||
image={imageUrl} | ||
onError={(e) => { | ||
e.currentTarget.onerror = null; | ||
e.currentTarget.src = `https://www.google.com/s2/favicons?sz=256&domain_url=${imageUrl}`; | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default IconWithPlaceholder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters