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 1
1
{
2
2
"name" : " @safe-global/safe-react-components" ,
3
- "version" : " 2.0.2 " ,
3
+ "version" : " 2.0.3 " ,
4
4
"description" : " Safe UI components" ,
5
5
"main" : " dist/index.min.js" ,
6
6
"typings" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
2
3
- import EthHashInfo from './' ;
3
+ import EthHashInfo , { type EthHashInfoProps } from './' ;
4
4
5
- export const Main = ( { size } ) : React . ReactElement => {
5
+ export const Main = ( {
6
+ size,
7
+ } : {
8
+ size ?: EthHashInfoProps [ 'avatarSize' ] ;
9
+ } ) : React . ReactElement => {
6
10
return (
7
11
< EthHashInfo
8
- avatarSize = { size || null }
12
+ avatarSize = { size }
9
13
showPrefix
10
14
prefix = "eth"
11
15
address = "0x40A2aCCbd92BCA938b02010E17A5b8929b49130D"
Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ const EthHashInfo = ({
50
50
const theme = useTheme ( ) ;
51
51
const isMobile = useMediaQuery ( theme . breakpoints . down ( 'sm' ) ) ;
52
52
53
+ const onError = React . useCallback ( ( ) => {
54
+ setFallbackToIdenticon ( true ) ;
55
+ } , [ ] ) ;
56
+
53
57
return (
54
58
< Container >
55
59
{ showAvatar && (
@@ -58,7 +62,7 @@ const EthHashInfo = ({
58
62
< img
59
63
src = { customAvatar }
60
64
alt = { address }
61
- onError = { ( ) => setFallbackToIdenticon ( true ) }
65
+ onError = { onError }
62
66
width = { avatarSize }
63
67
height = { avatarSize }
64
68
/>
@@ -82,11 +86,9 @@ const EthHashInfo = ({
82
86
< AddressContainer >
83
87
< Box fontWeight = "inherit" fontSize = "inherit" >
84
88
{ 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 >
90
92
</ Box >
91
93
92
94
{ showCopyButton && (
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ export type ExplorerButtonProps = {
10
10
href : string ;
11
11
} ;
12
12
13
+ const stopPropagation = ( e : React . SyntheticEvent ) => e . stopPropagation ( ) ;
14
+
13
15
const ExplorerButton = ( {
14
16
title,
15
17
href,
@@ -22,6 +24,7 @@ const ExplorerButton = ({
22
24
href = { href }
23
25
target = "_blank"
24
26
rel = "noopener noreferrer"
27
+ onClick = { stopPropagation }
25
28
size = "small" >
26
29
< Icon component = { LinkIcon } />
27
30
</ IconButton >
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ exports[`Storyshots Components/ExplorerButton Main 1`] = `
49
49
data-mui-internal-clone-element={true}
50
50
href="https://goerli.etherscan.io/address/0x51A099ac1BF46D471110AA8974024Bfe518Fd6C4"
51
51
onBlur={[Function]}
52
+ onClick={[Function]}
52
53
onContextMenu={[Function]}
53
54
onDragLeave={[Function]}
54
55
onFocus={[Function]}
You can’t perform that action at this time.
0 commit comments