Ensure only the copyable element itself is hover-able/click-able

This commit is contained in:
Nick Brown 2020-04-17 23:15:02 -07:00 committed by Michael Vines
parent 459b4d06fe
commit 73922609e4
3 changed files with 11 additions and 14 deletions

View File

@ -148,7 +148,7 @@ const renderAccountRow = (account: Account) => {
balance = `${(1.0 * account.lamports) / LAMPORTS_PER_SOL}`;
}
const base58AccountPubkey = account.pubkey.toBase58()
const base58AccountPubkey = account.pubkey.toBase58();
return (
<tr key={account.id}>
<td>

View File

@ -1,9 +1,9 @@
import React, { useState, ReactNode } from "react";
type CopyableProps = {
text: string
children: ReactNode
}
text: string;
children: ReactNode;
};
const popover = (
<div className="popover fade bs-popover-right show">
@ -17,20 +17,17 @@ function Copyable({ text, children }: CopyableProps) {
const copyToClipboard = () => navigator.clipboard.writeText(text);
const handleClick = () =>
copyToClipboard()
.then(() => {
setShowPopover(true);
setTimeout(setShowPopover.bind(null, false), 2500);
});
copyToClipboard().then(() => {
setShowPopover(true);
setTimeout(setShowPopover.bind(null, false), 2500);
});
return (
<div className="copyable">
<div onClick={handleClick}>
{children}
</div>
<div onClick={handleClick}>{children}</div>
{showPopover && popover}
</div>
);
}
export default Copyable;
export default Copyable;

View File

@ -13,7 +13,7 @@ code {
.copyable {
position: relative;
&:hover {
& > div:hover {
cursor: pointer;
}