Skip to content

Commit de284aa

Browse files
authored
Merge pull request #1680 from kleros/feat/address-explorer-link
feat(web): direct-address-to-explorer-in-account-display
2 parents dc91d63 + eddc472 commit de284aa

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

web/src/layout/Header/navbar/Menu/Settings/General.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useMemo } from "react";
22
import styled from "styled-components";
33

44
import { useAccount, useDisconnect } from "wagmi";
@@ -67,13 +67,30 @@ const UserContainer = styled.div`
6767
gap: 12px;
6868
`;
6969

70+
const StyledA = styled.a`
71+
text-decoration: none;
72+
label {
73+
cursor: pointer;
74+
color: ${({ theme }) => theme.primaryBlue};
75+
}
76+
77+
:hover {
78+
text-decoration: underline;
79+
}
80+
`;
81+
7082
export const DisconnectWalletButton: React.FC = () => {
7183
const { disconnect } = useDisconnect();
7284
return <Button text={`Disconnect`} onClick={() => disconnect()} />;
7385
};
7486

7587
const General: React.FC = () => {
76-
const { address } = useAccount();
88+
const { address, chain } = useAccount();
89+
90+
const addressExplorerLink = useMemo(() => {
91+
return `${chain?.blockExplorers?.default.url}/address/${address}`;
92+
}, [address, chain]);
93+
7794
return (
7895
<EnsureChainContainer>
7996
<EnsureChain>
@@ -84,7 +101,9 @@ const General: React.FC = () => {
84101
<IdenticonOrAvatar size="48" />
85102
</StyledAvatarContainer>
86103
<StyledAddressContainer>
87-
<AddressOrName />
104+
<StyledA href={addressExplorerLink} rel="noreferrer" target="_blank">
105+
<AddressOrName />
106+
</StyledA>
88107
</StyledAddressContainer>
89108
<StyledChainContainer>
90109
<ChainDisplay />

0 commit comments

Comments
 (0)