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
7fcdb2ce
Commit
7fcdb2ce
authored
Dec 25, 2023
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring
parent
82cc270e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
7 deletions
+10
-7
WalletMenuDesktop.tsx
ui/snippets/walletMenu/WalletMenuDesktop.tsx
+3
-1
WalletMenuMobile.tsx
ui/snippets/walletMenu/WalletMenuMobile.tsx
+3
-1
WalletTooltip.tsx
ui/snippets/walletMenu/WalletTooltip.tsx
+4
-5
No files found.
ui/snippets/walletMenu/WalletMenuDesktop.tsx
View file @
7fcdb2ce
...
@@ -2,6 +2,7 @@ import type { ButtonProps } from '@chakra-ui/react';
...
@@ -2,6 +2,7 @@ import type { ButtonProps } from '@chakra-ui/react';
import
{
Popover
,
PopoverContent
,
PopoverBody
,
PopoverTrigger
,
Button
,
Box
,
useBoolean
}
from
'
@chakra-ui/react
'
;
import
{
Popover
,
PopoverContent
,
PopoverBody
,
PopoverTrigger
,
Button
,
Box
,
useBoolean
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
AddressIdenticon
from
'
ui/shared/entities/address/AddressIdenticon
'
;
import
AddressIdenticon
from
'
ui/shared/entities/address/AddressIdenticon
'
;
import
HashStringShorten
from
'
ui/shared/HashStringShorten
'
;
import
HashStringShorten
from
'
ui/shared/HashStringShorten
'
;
import
useWallet
from
'
ui/snippets/walletMenu/useWallet
'
;
import
useWallet
from
'
ui/snippets/walletMenu/useWallet
'
;
...
@@ -18,6 +19,7 @@ const WalletMenuDesktop = ({ isHomePage }: Props) => {
...
@@ -18,6 +19,7 @@ const WalletMenuDesktop = ({ isHomePage }: Props) => {
const
{
isWalletConnected
,
address
,
connect
,
disconnect
,
isModalOpening
,
isModalOpen
}
=
useWallet
();
const
{
isWalletConnected
,
address
,
connect
,
disconnect
,
isModalOpening
,
isModalOpen
}
=
useWallet
();
const
{
themedBackground
,
themedBorderColor
,
themedColor
}
=
useMenuButtonColors
();
const
{
themedBackground
,
themedBorderColor
,
themedColor
}
=
useMenuButtonColors
();
const
[
isPopoverOpen
,
setIsPopoverOpen
]
=
useBoolean
(
false
);
const
[
isPopoverOpen
,
setIsPopoverOpen
]
=
useBoolean
(
false
);
const
isMobile
=
useIsMobile
();
const
variant
=
React
.
useMemo
(()
=>
{
const
variant
=
React
.
useMemo
(()
=>
{
if
(
isWalletConnected
)
{
if
(
isWalletConnected
)
{
...
@@ -55,7 +57,7 @@ const WalletMenuDesktop = ({ isHomePage }: Props) => {
...
@@ -55,7 +57,7 @@ const WalletMenuDesktop = ({ isHomePage }: Props) => {
isOpen=
{
isPopoverOpen
}
isOpen=
{
isPopoverOpen
}
onClose=
{
setIsPopoverOpen
.
off
}
onClose=
{
setIsPopoverOpen
.
off
}
>
>
<
WalletTooltip
isDisabled=
{
isWalletConnected
}
>
<
WalletTooltip
isDisabled=
{
isWalletConnected
||
isMobile
===
undefined
||
isMobile
}
>
<
Box
ml=
{
2
}
>
<
Box
ml=
{
2
}
>
<
PopoverTrigger
>
<
PopoverTrigger
>
<
Button
<
Button
...
...
ui/snippets/walletMenu/WalletMenuMobile.tsx
View file @
7fcdb2ce
...
@@ -2,6 +2,7 @@ import { Drawer, DrawerOverlay, DrawerContent, DrawerBody, useDisclosure, IconBu
...
@@ -2,6 +2,7 @@ import { Drawer, DrawerOverlay, DrawerContent, DrawerBody, useDisclosure, IconBu
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
walletIcon
from
'
icons/wallet.svg
'
;
import
walletIcon
from
'
icons/wallet.svg
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
AddressIdenticon
from
'
ui/shared/entities/address/AddressIdenticon
'
;
import
AddressIdenticon
from
'
ui/shared/entities/address/AddressIdenticon
'
;
import
useWallet
from
'
ui/snippets/walletMenu/useWallet
'
;
import
useWallet
from
'
ui/snippets/walletMenu/useWallet
'
;
import
WalletMenuContent
from
'
ui/snippets/walletMenu/WalletMenuContent
'
;
import
WalletMenuContent
from
'
ui/snippets/walletMenu/WalletMenuContent
'
;
...
@@ -13,10 +14,11 @@ const WalletMenuMobile = () => {
...
@@ -13,10 +14,11 @@ const WalletMenuMobile = () => {
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
const
{
isWalletConnected
,
address
,
connect
,
disconnect
,
isModalOpening
,
isModalOpen
}
=
useWallet
();
const
{
isWalletConnected
,
address
,
connect
,
disconnect
,
isModalOpening
,
isModalOpen
}
=
useWallet
();
const
{
themedBackground
,
themedBorderColor
,
themedColor
}
=
useMenuButtonColors
();
const
{
themedBackground
,
themedBorderColor
,
themedColor
}
=
useMenuButtonColors
();
const
isMobile
=
useIsMobile
();
return
(
return
(
<>
<>
<
WalletTooltip
isDisabled=
{
isWalletConnected
}
isMobile
>
<
WalletTooltip
isDisabled=
{
isWalletConnected
||
isMobile
===
undefined
||
!
isMobile
}
isMobile
>
<
IconButton
<
IconButton
aria
-
label=
"wallet menu"
aria
-
label=
"wallet menu"
icon=
{
isWalletConnected
?
icon=
{
isWalletConnected
?
...
...
ui/snippets/walletMenu/WalletTooltip.tsx
View file @
7fcdb2ce
...
@@ -18,18 +18,18 @@ const WalletTooltip = ({ children, isDisabled, isMobile }: Props) => {
...
@@ -18,18 +18,18 @@ const WalletTooltip = ({ children, isDisabled, isMobile }: Props) => {
const
label
=
isAppPage
?
const
label
=
isAppPage
?
<
span
>
Connect once to use your wallet with
<
br
/>
all apps in the DAppscout marketplace!
</
span
>
:
<
span
>
Connect once to use your wallet with
<
br
/>
all apps in the DAppscout marketplace!
</
span
>
:
defaultLabel
;
defaultLabel
;
const
localStorageKey
=
`
${
isAppPage
?
'
dapp-
'
:
''
}
wallet-connect-tooltip-shown
-
${
isMobile
?
'
mobile
'
:
'
desktop
'
}
`
;
const
localStorageKey
=
`
${
isAppPage
?
'
dapp-
'
:
''
}
wallet-connect-tooltip-shown`
;
return
{
defaultLabel
,
label
,
localStorageKey
};
return
{
defaultLabel
,
label
,
localStorageKey
};
},
[
router
.
pathname
,
isMobile
]);
},
[
router
.
pathname
]);
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
const
wasShown
=
window
.
localStorage
.
getItem
(
localStorageKey
);
const
wasShown
=
window
.
localStorage
.
getItem
(
localStorageKey
);
if
(
!
wasShown
)
{
if
(
!
isDisabled
&&
!
wasShown
)
{
setIsTooltipShown
.
on
();
setIsTooltipShown
.
on
();
window
.
localStorage
.
setItem
(
localStorageKey
,
'
true
'
);
window
.
localStorage
.
setItem
(
localStorageKey
,
'
true
'
);
setTimeout
(()
=>
setIsTooltipShown
.
off
(),
3000
);
setTimeout
(()
=>
setIsTooltipShown
.
off
(),
3000
);
}
}
},
[
setIsTooltipShown
,
localStorageKey
]);
},
[
setIsTooltipShown
,
localStorageKey
,
isDisabled
]);
return
(
return
(
<
Tooltip
<
Tooltip
...
@@ -40,7 +40,6 @@ const WalletTooltip = ({ children, isDisabled, isMobile }: Props) => {
...
@@ -40,7 +40,6 @@ const WalletTooltip = ({ children, isDisabled, isMobile }: Props) => {
openDelay=
{
300
}
openDelay=
{
300
}
isOpen=
{
isTooltipShown
||
(
isMobile
?
false
:
undefined
)
}
isOpen=
{
isTooltipShown
||
(
isMobile
?
false
:
undefined
)
}
onClose=
{
setIsTooltipShown
.
off
}
onClose=
{
setIsTooltipShown
.
off
}
display=
{
isMobile
?
{
base
:
'
flex
'
,
lg
:
'
none
'
}
:
{
base
:
'
none
'
,
lg
:
'
flex
'
}
}
>
>
{
children
}
{
children
}
</
Tooltip
>
</
Tooltip
>
...
...
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