Skip to content

Commit 1e680a7

Browse files
committed
chore: modified warning icon implem
1 parent 35631b1 commit 1e680a7

File tree

2 files changed

+39
-30
lines changed

2 files changed

+39
-30
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* Override the global a[target]::after external
2+
link icon that appeared on the warning sign */
3+
a.warningIcon[target]::after {
4+
content: none;
5+
display: none;
6+
}

src/components/WalletButton.tsx

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import {
66
Icon,
77
Tooltip,
88
} from "@stellar/design-system"
9-
import { useState } from "react"
9+
import React, { useState } from "react"
1010
import { useWallet } from "../hooks/useWallet"
1111
import { connectWallet, disconnectWallet } from "../util/wallet"
12+
import cssStyles from "./WalletButton.module.css"
1213

1314
export const WalletButton = () => {
1415
const [showDisconnectModal, setShowDisconnectModal] = useState(false)
@@ -28,12 +29,19 @@ export const WalletButton = () => {
2829
return warnings.join(". ")
2930
}
3031

31-
// Handle click on warning icon - open help URL if available
32-
const handleWarningClick = () => {
33-
if (walletWarnings.helpUrl) {
34-
window.open(walletWarnings.helpUrl, "_blank", "noopener,noreferrer")
35-
}
36-
}
32+
const warningIconStyles = {
33+
display: "flex",
34+
alignItems: "center",
35+
justifyContent: "center",
36+
overflow: "hidden",
37+
backgroundColor: "var(--color-gray-00, #fff)",
38+
borderRadius: "50%",
39+
padding: "3px",
40+
border: "2px solid var(--color-yellow-60, #f0ad4e)",
41+
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.2)",
42+
lineHeight: 0,
43+
textDecoration: "none",
44+
} as const
3745

3846
if (!address) {
3947
return (
@@ -136,33 +144,28 @@ export const WalletButton = () => {
136144
isVisible={isWarningTooltipVisible}
137145
isContrast
138146
placement="bottom"
139-
triggerEl={
140-
<div
141-
onClick={handleWarningClick}
147+
triggerEl={React.createElement(
148+
walletWarnings.helpUrl ? "a" : "span",
149+
walletWarnings.helpUrl
150+
? {
151+
href: walletWarnings.helpUrl,
152+
target: "_blank",
153+
className: cssStyles.warningIcon,
154+
style: warningIconStyles,
155+
}
156+
: { style: warningIconStyles },
157+
<Icon.AlertTriangle
142158
style={{
143-
display: "flex",
144-
alignItems: "center",
145-
justifyContent: "center",
146-
cursor: "pointer",
147-
backgroundColor: "var(--color-gray-00, #fff)",
148-
borderRadius: "50%",
149-
padding: "3px",
150-
border: "2px solid var(--color-yellow-60, #f0ad4e)",
151-
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.2)",
159+
color: "var(--color-yellow-60, #f0ad4e)",
160+
width: "12px",
161+
height: "12px",
152162
}}
153-
>
154-
<Icon.AlertTriangle
155-
style={{
156-
color: "var(--color-yellow-60, #f0ad4e)",
157-
width: "12px",
158-
height: "12px",
159-
}}
160-
/>
161-
</div>
162-
}
163+
/>,
164+
)}
163165
>
164166
<div style={{ maxWidth: "15em" }}>
165-
{getWarningMessage()}. Click to learn more about this issue.
167+
{getWarningMessage()}
168+
{walletWarnings.helpUrl ? ". Click to learn more." : ""}
166169
</div>
167170
</Tooltip>
168171
</div>

0 commit comments

Comments
 (0)