Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace onClick listeners with links #15

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/Account/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
border-radius: 12px;
background: var(--white);
padding: 0.7125rem;
text-decoration: none;
cursor: pointer;
}

Expand Down Expand Up @@ -48,6 +49,7 @@
.account {
position: fixed;
display: inline-flex;
text-decoration: none;
width: auto;
top: 2.875rem;
right: 2.5rem;
Expand Down
10 changes: 3 additions & 7 deletions src/components/Account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,17 @@ export const Account: FC<Props> = ({ address, networkName }) => {
state: { explorerBaseUrl },
} = useWeb3()

const handleAccountClick = () => {
if (explorerBaseUrl) {
window.open(StringUtils.getAccountUrl(explorerBaseUrl, address), '_blank', 'noopener,noreferrer')
}
}
const url = explorerBaseUrl ? StringUtils.getAccountUrl(explorerBaseUrl, address) : '#'

return (
<div className={classes.account} onClick={handleAccountClick}>
<a href={url} className={classes.account} target="_blank" rel="nofollow noreferrer">
<JazzIcon size={isXlScreen ? 60 : 30} address={address} />
<p className={classes.accountDetails}>
<abbr title={address} className={classes.accountAddress}>
{StringUtils.truncateAddress(address)}
</abbr>
<span className={classes.network}>{networkName}</span>
</p>
</div>
</a>
)
}
17 changes: 5 additions & 12 deletions src/pages/ConnectWallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ export const ConnectWallet: FC = () => {
}
}

const handleInstallMetaMask = async () => {
window.open(METAMASK_HOME_PAGE, '_blank', 'noopener,noreferrer')
}

return (
<>
{!hasMetaMaskWallet && (
Expand All @@ -65,14 +61,11 @@ export const ConnectWallet: FC = () => {
MetaMask not detected, please install it.
</p>

<Button
className={classes.installMetaMaskBtn}
onClick={handleInstallMetaMask}
fullWidth
disabled={isLoading}
>
Install MetaMask
</Button>
<a href={METAMASK_HOME_PAGE} target={'_blank'} rel={'noopener noreferrer'}>
<Button className={classes.installMetaMaskBtn} fullWidth disabled={isLoading}>
Install MetaMask
</Button>
</a>
<Button
variant="secondary"
onClick={() => setHasMetaMaskWallet(true)}
Expand Down
4 changes: 4 additions & 0 deletions src/pages/Transaction/index.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.noUnderlineLink {
text-decoration: none;
}

.openInExplorerBtn {
display: flex;
justify-content: center;
Expand Down
19 changes: 8 additions & 11 deletions src/pages/Transaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ export const Transaction: FC = () => {
init()
}, [getTransaction, navigate, txHash])

const handleNavigateToExplorer = () => {
if (explorerBaseUrl && txHash) {
const txUrl = StringUtils.getTransactionUrl(explorerBaseUrl, txHash)
window.open(txUrl, '_blank', 'noopener,noreferrer')
}
}
const txUrl = explorerBaseUrl && txHash ? StringUtils.getTransactionUrl(explorerBaseUrl, txHash) : undefined

const handleNavigateBack = () => {
navigate('/wrapper')
Expand Down Expand Up @@ -92,11 +87,13 @@ export const Transaction: FC = () => {
{type === TransactionType.Rose && <b>&nbsp;{amount} ROSE</b>}
</h3>

{explorerBaseUrl && txHash && (
<Button className={classes.openInExplorerBtn} onClick={handleNavigateToExplorer} fullWidth>
View on explorer
<OpenInNewIcon />
</Button>
{txUrl && (
<a className={classes.noUnderlineLink} href={txUrl} target="_blank" rel="noopener noreferrer">
<Button className={classes.openInExplorerBtn} fullWidth>
View on explorer
<OpenInNewIcon />
</Button>
</a>
)}
<Button variant="secondary" onClick={handleNavigateBack} fullWidth>
Close
Expand Down