Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
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
LuckySwap
interface
Commits
8cd32138
Unverified
Commit
8cd32138
authored
Nov 18, 2022
by
lynn
Committed by
GitHub
Nov 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: erc 1155 tooltip behavior on mobile (#5305)
fix erc 1155 tooltip behavior on mobile
parent
785c2a67
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
12 deletions
+30
-12
index.tsx
src/components/Tooltip/index.tsx
+18
-3
ViewMyNftsAsset.tsx
src/nft/components/profile/view/ViewMyNftsAsset.tsx
+12
-9
No files found.
src/components/Tooltip/index.tsx
View file @
8cd32138
import
{
transparentize
}
from
'
polished
'
import
{
transparentize
}
from
'
polished
'
import
{
ReactNode
,
useCallback
,
useState
}
from
'
react
'
import
{
ReactNode
,
useCallback
,
use
Effect
,
use
State
}
from
'
react
'
import
styled
from
'
styled-components/macro
'
import
styled
from
'
styled-components/macro
'
import
Popover
,
{
PopoverProps
}
from
'
../Popover
'
import
Popover
,
{
PopoverProps
}
from
'
../Popover
'
...
@@ -23,6 +23,7 @@ interface TooltipProps extends Omit<PopoverProps, 'content'> {
...
@@ -23,6 +23,7 @@ interface TooltipProps extends Omit<PopoverProps, 'content'> {
close
?:
()
=>
void
close
?:
()
=>
void
noOp
?:
()
=>
void
noOp
?:
()
=>
void
disableHover
?:
boolean
// disable the hover and content display
disableHover
?:
boolean
// disable the hover and content display
timeout
?:
number
}
}
interface
TooltipContentProps
extends
Omit
<
PopoverProps
,
'
content
'
>
{
interface
TooltipContentProps
extends
Omit
<
PopoverProps
,
'
content
'
>
{
...
@@ -53,10 +54,24 @@ function TooltipContent({ content, wrap = false, ...rest }: TooltipContentProps)
...
@@ -53,10 +54,24 @@ function TooltipContent({ content, wrap = false, ...rest }: TooltipContentProps)
}
}
/** Standard text tooltip. */
/** Standard text tooltip. */
export
function
MouseoverTooltip
({
text
,
disableHover
,
children
,
...
rest
}:
Omit
<
TooltipProps
,
'
show
'
>
)
{
export
function
MouseoverTooltip
({
text
,
disableHover
,
children
,
timeout
,
...
rest
}:
Omit
<
TooltipProps
,
'
show
'
>
)
{
const
[
show
,
setShow
]
=
useState
(
false
)
const
[
show
,
setShow
]
=
useState
(
false
)
const
open
=
useCallback
(()
=>
setShow
(
true
),
[
setShow
])
const
open
=
useCallback
(()
=>
setShow
(
true
),
[
setShow
])
const
close
=
useCallback
(()
=>
setShow
(
false
),
[
setShow
])
const
close
=
useCallback
(()
=>
setShow
(
false
),
[
setShow
])
useEffect
(()
=>
{
if
(
show
&&
timeout
)
{
const
tooltipTimer
=
setTimeout
(()
=>
{
setShow
(
false
)
},
timeout
)
return
()
=>
{
clearTimeout
(
tooltipTimer
)
}
}
return
},
[
timeout
,
show
])
const
noOp
=
()
=>
null
const
noOp
=
()
=>
null
return
(
return
(
<
Tooltip
<
Tooltip
...
@@ -68,7 +83,7 @@ export function MouseoverTooltip({ text, disableHover, children, ...rest }: Omit
...
@@ -68,7 +83,7 @@ export function MouseoverTooltip({ text, disableHover, children, ...rest }: Omit
show=
{
show
}
show=
{
show
}
text=
{
disableHover
?
null
:
text
}
text=
{
disableHover
?
null
:
text
}
>
>
<
div
onMouseEnter=
{
disableHover
?
noOp
:
open
}
onMouseLeave=
{
disableHover
?
noOp
:
close
}
>
<
div
onMouseEnter=
{
disableHover
?
noOp
:
open
}
onMouseLeave=
{
disableHover
||
timeout
?
noOp
:
close
}
>
{
children
}
{
children
}
</
div
>
</
div
>
</
Tooltip
>
</
Tooltip
>
...
...
src/nft/components/profile/view/ViewMyNftsAsset.tsx
View file @
8cd32138
...
@@ -34,6 +34,16 @@ const getNftDisplayComponent = (
...
@@ -34,6 +34,16 @@ const getNftDisplayComponent = (
}
}
}
}
const
getUnsupportedNftTextComponent
=
(
asset
:
WalletAsset
)
=>
(
<
Box
as=
"span"
className=
{
bodySmall
}
style=
{
{
color
:
themeVars
.
colors
.
textPrimary
}
}
>
{
asset
.
asset_contract
.
tokenType
===
TokenType
.
ERC1155
?
(
<
Trans
>
ERC-1155 support coming soon
</
Trans
>
)
:
(
<
Trans
>
Blocked from trading
</
Trans
>
)
}
</
Box
>
)
export
const
ViewMyNftsAsset
=
({
export
const
ViewMyNftsAsset
=
({
asset
,
asset
,
mediaShouldBePlaying
,
mediaShouldBePlaying
,
...
@@ -113,20 +123,13 @@ export const ViewMyNftsAsset = ({
...
@@ -113,20 +123,13 @@ export const ViewMyNftsAsset = ({
placement=
"bottom"
placement=
"bottom"
>
>
<
MouseoverTooltip
<
MouseoverTooltip
text=
{
text=
{
getUnsupportedNftTextComponent
(
asset
)
}
<
Box
as=
"span"
className=
{
bodySmall
}
style=
{
{
color
:
themeVars
.
colors
.
textPrimary
}
}
>
{
asset
.
asset_contract
.
tokenType
===
TokenType
.
ERC1155
?
(
<
Trans
>
ERC-1155 support coming soon
</
Trans
>
)
:
(
<
Trans
>
Blocked from trading
</
Trans
>
)
}
</
Box
>
}
placement=
"bottom"
placement=
"bottom"
offsetX=
{
0
}
offsetX=
{
0
}
offsetY=
{
-
100
}
offsetY=
{
-
100
}
style=
{
{
display
:
'
block
'
}
}
style=
{
{
display
:
'
block
'
}
}
disableHover=
{
!
isDisabled
}
disableHover=
{
!
isDisabled
}
timeout=
{
isMobile
?
TOOLTIP_TIMEOUT
:
undefined
}
>
>
{
getNftDisplayComponent
(
assetMediaType
,
mediaShouldBePlaying
,
setCurrentTokenPlayingMedia
)
}
{
getNftDisplayComponent
(
assetMediaType
,
mediaShouldBePlaying
,
setCurrentTokenPlayingMedia
)
}
</
MouseoverTooltip
>
</
MouseoverTooltip
>
...
...
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