Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
0e4d9de6
Commit
0e4d9de6
authored
Nov 09, 2023
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tooltip for wallet connect button
parent
4e306451
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
23 deletions
+43
-23
WalletMenuDesktop.tsx
ui/snippets/walletMenu/WalletMenuDesktop.tsx
+43
-23
No files found.
ui/snippets/walletMenu/WalletMenuDesktop.tsx
View file @
0e4d9de6
import
type
{
ButtonProps
}
from
'
@chakra-ui/react
'
;
import
{
Popover
,
PopoverContent
,
PopoverBody
,
PopoverTrigger
,
Button
,
useColorModeValue
,
Box
,
useBoolean
}
from
'
@chakra-ui/react
'
;
import
{
Popover
,
PopoverContent
,
PopoverBody
,
PopoverTrigger
,
Button
,
useColorModeValue
,
Box
,
useBoolean
,
Tooltip
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
AddressIdenticon
from
'
ui/shared/entities/address/AddressIdenticon
'
;
...
...
@@ -14,6 +14,15 @@ type Props = {
const
WalletMenuDesktop
=
({
isHomePage
}:
Props
)
=>
{
const
{
isWalletConnected
,
address
,
connect
,
disconnect
,
isModalOpening
,
isModalOpen
}
=
useWallet
();
const
[
isPopoverOpen
,
setIsPopoverOpen
]
=
useBoolean
(
false
);
const
[
isTooltipShown
,
setIsTooltipShown
]
=
useBoolean
(
false
);
React
.
useEffect
(()
=>
{
const
wasShown
=
window
.
localStorage
.
getItem
(
'
wallet-connect-tooltip-shown
'
);
if
(
!
wasShown
)
{
setIsTooltipShown
.
on
();
window
.
localStorage
.
setItem
(
'
wallet-connect-tooltip-shown
'
,
'
true
'
);
}
},
[
setIsTooltipShown
]);
const
variant
=
React
.
useMemo
(()
=>
{
if
(
isWalletConnected
)
{
...
...
@@ -54,28 +63,39 @@ const WalletMenuDesktop = ({ isHomePage }: Props) => {
isOpen=
{
isPopoverOpen
}
onClose=
{
setIsPopoverOpen
.
off
}
>
<
PopoverTrigger
>
<
Button
variant=
{
variant
}
colorScheme=
"blue"
flexShrink=
{
0
}
isLoading=
{
isModalOpening
||
isModalOpen
}
loadingText=
"Connect wallet"
onClick=
{
isWalletConnected
?
setIsPopoverOpen
.
on
:
connect
}
ml=
{
3
}
fontSize=
"sm"
{
...
buttonStyles
}
>
{
isWalletConnected
?
(
<>
<
Box
mr=
{
2
}
>
<
AddressIdenticon
size=
{
20
}
hash=
{
address
}
/>
</
Box
>
<
HashStringShorten
hash=
{
address
}
isTooltipDisabled
/>
</>
)
:
'
Connect wallet
'
}
</
Button
>
</
PopoverTrigger
>
<
Tooltip
label=
{
<
span
>
Your wallet is used to interact with
<
br
/>
apps and contracts in the explorer
</
span
>
}
textAlign=
"center"
padding=
{
2
}
isDisabled=
{
isWalletConnected
}
openDelay=
{
300
}
isOpen=
{
isTooltipShown
||
undefined
}
onClose=
{
setIsTooltipShown
.
off
}
>
<
Box
ml=
{
3
}
>
<
PopoverTrigger
>
<
Button
variant=
{
variant
}
colorScheme=
"blue"
flexShrink=
{
0
}
isLoading=
{
isModalOpening
||
isModalOpen
}
loadingText=
"Connect wallet"
onClick=
{
isWalletConnected
?
setIsPopoverOpen
.
on
:
connect
}
fontSize=
"sm"
{
...
buttonStyles
}
>
{
isWalletConnected
?
(
<>
<
Box
mr=
{
2
}
>
<
AddressIdenticon
size=
{
20
}
hash=
{
address
}
/>
</
Box
>
<
HashStringShorten
hash=
{
address
}
isTooltipDisabled
/>
</>
)
:
'
Connect wallet
'
}
</
Button
>
</
PopoverTrigger
>
</
Box
>
</
Tooltip
>
{
isWalletConnected
&&
(
<
PopoverContent
w=
"235px"
>
<
PopoverBody
padding=
"24px 16px 16px 16px"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment