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
847ec0a2
Commit
847ec0a2
authored
Apr 15, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update tooltips
parent
bf0b87ac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
20 deletions
+37
-20
WalletMenuDesktop.tsx
ui/snippets/walletMenu/WalletMenuDesktop.tsx
+5
-1
WalletMenuMobile.tsx
ui/snippets/walletMenu/WalletMenuMobile.tsx
+6
-1
WalletTooltip.tsx
ui/snippets/walletMenu/WalletTooltip.tsx
+26
-18
No files found.
ui/snippets/walletMenu/WalletMenuDesktop.tsx
View file @
847ec0a2
...
...
@@ -70,7 +70,11 @@ const WalletMenuDesktop = ({ isHomePage, className, size = 'md' }: Props) => {
isOpen=
{
isPopoverOpen
}
onClose=
{
setIsPopoverOpen
.
off
}
>
<
WalletTooltip
isDisabled=
{
isWalletConnected
||
isMobile
===
undefined
||
isMobile
}
>
<
WalletTooltip
isDisabled=
{
isMobile
===
undefined
||
isMobile
}
isWalletConnected=
{
isWalletConnected
}
isAutoConnectDisabled=
{
isAutoConnectDisabled
}
>
<
Box
ml=
{
2
}
>
<
PopoverTrigger
>
<
Button
...
...
ui/snippets/walletMenu/WalletMenuMobile.tsx
View file @
847ec0a2
...
...
@@ -28,7 +28,12 @@ const WalletMenuMobile = () => {
return
(
<>
<
WalletTooltip
isDisabled=
{
isWalletConnected
||
isMobile
===
undefined
||
!
isMobile
}
isMobile
>
<
WalletTooltip
isDisabled=
{
isMobile
===
undefined
||
!
isMobile
}
isMobile
isWalletConnected=
{
isWalletConnected
}
isAutoConnectDisabled=
{
isAutoConnectDisabled
}
>
<
IconButton
aria
-
label=
"wallet menu"
icon=
{
isWalletConnected
?
...
...
ui/snippets/walletMenu/WalletTooltip.tsx
View file @
847ec0a2
...
...
@@ -9,38 +9,46 @@ type Props = {
children
:
React
.
ReactNode
;
isDisabled
?:
boolean
;
isMobile
?:
boolean
;
isWalletConnected
?:
boolean
;
isAutoConnectDisabled
?:
boolean
;
};
const
WalletTooltip
=
({
children
,
isDisabled
,
isMobile
}:
Props
)
=>
{
const
LOCAL_STORAGE_KEY
=
'
wallet-connect-tooltip-shown
'
;
const
WalletTooltip
=
({
children
,
isDisabled
,
isMobile
,
isWalletConnected
,
isAutoConnectDisabled
}:
Props
)
=>
{
const
router
=
useRouter
();
const
[
isTooltipShown
,
setIsTooltipShown
]
=
useBoolean
(
false
);
const
ref
=
React
.
useRef
(
null
);
useOutsideClick
({
ref
,
handler
:
setIsTooltipShown
.
off
});
const
{
defaultLabel
,
label
,
localStorageKey
}
=
React
.
useMemo
(()
=>
{
const
isAppPage
=
router
.
pathname
===
'
/apps/[id]
'
;
const
defaultLabel
=
<
span
>
Your wallet is used to interact with
<
br
/>
apps and contracts in the explorer
</
span
>;
const
label
=
isAppPage
?
<
span
>
Connect once to use your wallet with
<
br
/>
all apps in the DAppscout marketplace!
</
span
>
:
defaultLabel
;
const
localStorageKey
=
`
${
isAppPage
?
'
dapp-
'
:
''
}
wallet-connect-tooltip-shown`
;
return
{
defaultLabel
,
label
,
localStorageKey
};
},
[
router
.
pathname
]);
const
label
=
React
.
useMemo
(()
=>
{
if
(
isWalletConnected
)
{
if
(
isAutoConnectDisabled
)
{
return
<
span
>
Your wallet is not
<
br
/>
connected to this app.
<
br
/>
Connect your wallet
<
br
/>
in the app directly
</
span
>;
}
return
<
span
>
Your wallet is connected
<
br
/>
with Blockscout
</
span
>;
}
return
<
span
>
Connect your wallet
<
br
/>
to Blockscout for
<
br
/>
full-featured access
</
span
>;
},
[
isWalletConnected
,
isAutoConnectDisabled
]);
const
isAppPage
=
router
.
pathname
===
'
/apps/[id]
'
;
React
.
useEffect
(()
=>
{
const
wasShown
=
window
.
localStorage
.
getItem
(
localStorageKey
);
const
isMarketplacePage
=
[
'
/apps
'
,
'
/apps/[id]
'
].
includes
(
router
.
pathname
)
;
const
wasShown
=
window
.
localStorage
.
getItem
(
LOCAL_STORAGE_KEY
);
const
isMarketplacePage
=
router
.
pathname
===
'
/apps
'
;
const
isTooltipShowAction
=
router
.
query
.
action
===
'
tooltip
'
;
const
isConnectWalletAction
=
router
.
query
.
action
===
'
connect
'
;
const
needToShow
=
(
!
wasShown
&&
!
isConnectWalletAction
)
||
isTooltipShowAction
;
const
needToShow
=
(
isAppPage
&&
!
isConnectWalletAction
)
||
isTooltipShowAction
||
(
!
wasShown
&&
isMarketplacePage
)
;
let
timer1
:
ReturnType
<
typeof
setTimeout
>
;
let
timer2
:
ReturnType
<
typeof
setTimeout
>
;
if
(
!
isDisabled
&&
isMarketplacePage
&&
needToShow
)
{
if
(
!
isDisabled
&&
needToShow
)
{
timer1
=
setTimeout
(()
=>
{
setIsTooltipShown
.
on
();
window
.
localStorage
.
setItem
(
localStorageKey
,
'
true
'
);
timer2
=
setTimeout
(()
=>
setIsTooltipShown
.
off
(),
5
*
SECOND
);
if
(
!
wasShown
&&
isMarketplacePage
)
{
window
.
localStorage
.
setItem
(
LOCAL_STORAGE_KEY
,
'
true
'
);
}
if
(
isTooltipShowAction
)
{
removeQueryParam
(
router
,
'
action
'
);
}
...
...
@@ -51,14 +59,14 @@ const WalletTooltip = ({ children, isDisabled, isMobile }: Props) => {
clearTimeout
(
timer1
);
clearTimeout
(
timer2
);
};
},
[
setIsTooltipShown
,
localStorageKey
,
isDisabled
,
router
]);
},
[
setIsTooltipShown
,
isDisabled
,
router
,
isAppPage
]);
return
(
<
Tooltip
label=
{
isTooltipShown
?
label
:
defaultL
abel
}
label=
{
l
abel
}
textAlign=
"center"
padding=
{
2
}
isDisabled=
{
isDisabled
}
isDisabled=
{
isDisabled
||
(
isWalletConnected
&&
!
isAppPage
)
}
openDelay=
{
500
}
isOpen=
{
isTooltipShown
||
(
isMobile
?
false
:
undefined
)
}
onClose=
{
setIsTooltipShown
.
off
}
...
...
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