Skip to content

Commit cf7ad5e

Browse files
committed
chore: simplify tooltip
1 parent b12873a commit cf7ad5e

File tree

3 files changed

+36
-56
lines changed

3 files changed

+36
-56
lines changed
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
/* Override the global a[target]::after external
22
link icon that appeared on the warning sign */
3-
a.warningIcon[target]::after {
3+
.learnMore[target]::after {
44
content: none;
55
display: none;
66
}
7+
.learnMore {
8+
color: var(--sds-clr-lilac-09, #606);
9+
}
10+
11+
.warningIcon {
12+
height: 20px;
13+
width: 20px;
14+
color: var(--color-yellow-60, #f0ad4e);
15+
position: absolute;
16+
bottom: -8px;
17+
right: -8px;
18+
cursor: pointer;
19+
}
20+
21+
.profileWrap {
22+
position: relative;
23+
}

src/components/WalletButton.tsx

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,9 @@ import cssStyles from "./WalletButton.module.css"
1313

1414
export const WalletButton = () => {
1515
const [showDisconnectModal, setShowDisconnectModal] = useState(false)
16-
const [isWarningTooltipVisible, setIsWarningTooltipVisible] = useState(false)
1716
const { address, isPending, balances, walletWarnings } = useWallet()
1817
const buttonLabel = isPending ? "Loading..." : "Connect"
1918

20-
const warningIconStyles = {
21-
display: "flex",
22-
alignItems: "center",
23-
justifyContent: "center",
24-
overflow: "hidden",
25-
backgroundColor: "var(--color-gray-00, #fff)",
26-
borderRadius: "50%",
27-
padding: "3px",
28-
border: "2px solid var(--color-yellow-60, #f0ad4e)",
29-
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.2)",
30-
lineHeight: 0,
31-
textDecoration: "none",
32-
} as const
33-
3419
if (!address) {
3520
return (
3621
<Button variant="primary" size="md" onClick={() => void connectWallet()}>
@@ -109,7 +94,7 @@ export const WalletButton = () => {
10994
</Modal>
11095
</div>
11196

112-
<div style={{ position: "relative" }}>
97+
<div className={cssStyles.profileWrap}>
11398
<Profile
11499
publicAddress={address}
115100
size="md"
@@ -118,45 +103,23 @@ export const WalletButton = () => {
118103
/>
119104

120105
{walletWarnings.hasWarnings && (
121-
<div
122-
onMouseEnter={() => setIsWarningTooltipVisible(true)}
123-
onMouseLeave={() => setIsWarningTooltipVisible(false)}
124-
style={{
125-
position: "absolute",
126-
top: "-6px",
127-
right: "-6px",
128-
zIndex: 1,
129-
}}
106+
<Tooltip
107+
placement="bottom"
108+
triggerEl={<Icon.AlertTriangle className={cssStyles.warningIcon} />}
130109
>
131-
<Tooltip
132-
isVisible={isWarningTooltipVisible}
133-
isContrast
134-
placement="bottom"
135-
triggerEl={React.createElement(
136-
walletWarnings.helpUrl ? "a" : "span",
137-
walletWarnings.helpUrl
138-
? {
139-
href: walletWarnings.helpUrl,
140-
target: "_blank",
141-
className: cssStyles.warningIcon,
142-
style: warningIconStyles,
143-
}
144-
: { style: warningIconStyles },
145-
<Icon.AlertTriangle
146-
style={{
147-
color: "var(--color-yellow-60, #f0ad4e)",
148-
width: "12px",
149-
height: "12px",
150-
}}
151-
/>,
110+
<div style={{ maxWidth: "15em" }}>
111+
{walletWarnings.messages.join("")}
112+
{walletWarnings.helpUrl && (
113+
<a
114+
className={cssStyles.learnMore}
115+
href={walletWarnings.helpUrl}
116+
target="_blank"
117+
>
118+
Learn more
119+
</a>
152120
)}
153-
>
154-
<div style={{ maxWidth: "15em" }}>
155-
{walletWarnings.messages.join(". ")}
156-
{walletWarnings.helpUrl ? ". Click to learn more." : ""}
157-
</div>
158-
</Tooltip>
159-
</div>
121+
</div>
122+
</Tooltip>
160123
)}
161124
</div>
162125
</div>

src/providers/WalletProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ function getWalletWarnings(walletId: string | null): WalletWarnings {
109109

110110
const messages: string[] = []
111111
if (popupAlways) {
112-
messages.push("This wallet triggers a popup on every interaction")
112+
messages.push("This wallet triggers a popup on every interaction. ")
113113
}
114114
if (noGetNetworkSupport) {
115-
messages.push("This wallet doesn't support network detection")
115+
messages.push("This wallet doesn't support network detection. ")
116116
}
117117

118118
return {

0 commit comments

Comments
 (0)