This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +20
-10
lines changed
tests/src/components/ExplorerButton/__snapshots__ Expand file tree Collapse file tree 5 files changed +20
-10
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @safe-global/safe-react-components" ,
3- "version" : " 2.0.2 " ,
3+ "version" : " 2.0.3 " ,
44 "description" : " Safe UI components" ,
55 "main" : " dist/index.min.js" ,
66 "typings" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
22
3- import EthHashInfo from './' ;
3+ import EthHashInfo , { type EthHashInfoProps } from './' ;
44
5- export const Main = ( { size } ) : React . ReactElement => {
5+ export const Main = ( {
6+ size,
7+ } : {
8+ size ?: EthHashInfoProps [ 'avatarSize' ] ;
9+ } ) : React . ReactElement => {
610 return (
711 < EthHashInfo
8- avatarSize = { size || null }
12+ avatarSize = { size }
913 showPrefix
1014 prefix = "eth"
1115 address = "0x40A2aCCbd92BCA938b02010E17A5b8929b49130D"
Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ const EthHashInfo = ({
5050 const theme = useTheme ( ) ;
5151 const isMobile = useMediaQuery ( theme . breakpoints . down ( 'sm' ) ) ;
5252
53+ const onError = React . useCallback ( ( ) => {
54+ setFallbackToIdenticon ( true ) ;
55+ } , [ ] ) ;
56+
5357 return (
5458 < Container >
5559 { showAvatar && (
@@ -58,7 +62,7 @@ const EthHashInfo = ({
5862 < img
5963 src = { customAvatar }
6064 alt = { address }
61- onError = { ( ) => setFallbackToIdenticon ( true ) }
65+ onError = { onError }
6266 width = { avatarSize }
6367 height = { avatarSize }
6468 />
@@ -82,11 +86,9 @@ const EthHashInfo = ({
8286 < AddressContainer >
8387 < Box fontWeight = "inherit" fontSize = "inherit" >
8488 { showPrefix && shouldPrefix && prefix && < b > { prefix } :</ b > }
85- { isMobile ? (
86- < span > { shortenAddress ( address ) } </ span >
87- ) : (
88- < span > { shortAddress ? shortenAddress ( address ) : address } </ span >
89- ) }
89+ < span >
90+ { shortAddress || isMobile ? shortenAddress ( address ) : address }
91+ </ span >
9092 </ Box >
9193
9294 { showCopyButton && (
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ export type ExplorerButtonProps = {
1010 href : string ;
1111} ;
1212
13+ const stopPropagation = ( e : React . SyntheticEvent ) => e . stopPropagation ( ) ;
14+
1315const ExplorerButton = ( {
1416 title,
1517 href,
@@ -22,6 +24,7 @@ const ExplorerButton = ({
2224 href = { href }
2325 target = "_blank"
2426 rel = "noopener noreferrer"
27+ onClick = { stopPropagation }
2528 size = "small" >
2629 < Icon component = { LinkIcon } />
2730 </ IconButton >
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ exports[`Storyshots Components/ExplorerButton Main 1`] = `
4949 data-mui-internal-clone-element={true}
5050 href="https://goerli.etherscan.io/address/0x51A099ac1BF46D471110AA8974024Bfe518Fd6C4"
5151 onBlur={[Function]}
52+ onClick={[Function]}
5253 onContextMenu={[Function]}
5354 onDragLeave={[Function]}
5455 onFocus={[Function]}
You can’t perform that action at this time.
0 commit comments