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
78016951
Unverified
Commit
78016951
authored
May 04, 2021
by
AmagiDDmxh
Committed by
GitHub
May 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(block number): Update polling block number breathing behavior (#1379)
parent
5a9034fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
13 deletions
+22
-13
Polling.tsx
src/components/Header/Polling.tsx
+22
-13
No files found.
src/components/Header/Polling.tsx
View file @
78016951
...
@@ -9,27 +9,29 @@ import { useActiveWeb3React } from '../../hooks'
...
@@ -9,27 +9,29 @@ import { useActiveWeb3React } from '../../hooks'
const
StyledPolling
=
styled
.
div
`
const
StyledPolling
=
styled
.
div
`
position: fixed;
position: fixed;
display: flex;
display: flex;
align-items: center;
right: 0;
right: 0;
bottom: 0;
bottom: 0;
padding: 1rem;
padding: 1rem;
color: white;
transition: opacity 0.25s ease;
color:
${({
theme
})
=>
theme
.
green1
}
;
color:
${({
theme
})
=>
theme
.
green1
}
;
:hover {
opacity: 1;
}
${({
theme
})
=>
theme
.
mediaWidth
.
upToMedium
`
${({
theme
})
=>
theme
.
mediaWidth
.
upToMedium
`
display: none;
display: none;
`
}
`
}
`
`
const
StyledPollingNumber
=
styled
(
TYPE
.
small
)
<
{
breathe
:
boolean
;
hovering
:
boolean
}
>
`
transition: opacity 0.25s ease;
opacity:
${({
breathe
,
hovering
})
=>
(
hovering
?
0.7
:
breathe
?
1
:
0.2
)}
;
:hover {
opacity: 1;
}
`
const
StyledPollingDot
=
styled
.
div
`
const
StyledPollingDot
=
styled
.
div
`
width: 8px;
width: 8px;
height: 8px;
height: 8px;
min-height: 8px;
min-height: 8px;
min-width: 8px;
min-width: 8px;
margin-left: 0.5rem;
margin-left: 0.5rem;
margin-top: 3px;
border-radius: 50%;
border-radius: 50%;
position: relative;
position: relative;
background-color:
${({
theme
})
=>
theme
.
green1
}
;
background-color:
${({
theme
})
=>
theme
.
green1
}
;
...
@@ -67,16 +69,21 @@ export default function Polling() {
...
@@ -67,16 +69,21 @@ export default function Polling() {
const
blockNumber
=
useBlockNumber
()
const
blockNumber
=
useBlockNumber
()
const
[
isMounted
,
setIsMounted
]
=
useState
(
true
)
const
[
isMounting
,
setIsMounting
]
=
useState
(
false
)
const
[
isHover
,
setIsHover
]
=
useState
(
false
)
useEffect
(
useEffect
(
()
=>
{
()
=>
{
const
timer1
=
setTimeout
(()
=>
setIsMounted
(
true
),
1000
)
if
(
!
blockNumber
)
{
return
}
setIsMounting
(
true
)
const
mountingTimer
=
setTimeout
(()
=>
setIsMounting
(
false
),
1000
)
// this will clear Timeout when component unmount like in willComponentUnmount
// this will clear Timeout when component unmount like in willComponentUnmount
return
()
=>
{
return
()
=>
{
setIsMounted
(
false
)
clearTimeout
(
mountingTimer
)
clearTimeout
(
timer1
)
}
}
},
},
[
blockNumber
]
//useEffect will run only one time
[
blockNumber
]
//useEffect will run only one time
...
@@ -85,9 +92,11 @@ export default function Polling() {
...
@@ -85,9 +92,11 @@ export default function Polling() {
return
(
return
(
<
ExternalLink
href=
{
chainId
&&
blockNumber
?
getEtherscanLink
(
chainId
,
blockNumber
.
toString
(),
'
block
'
)
:
''
}
>
<
ExternalLink
href=
{
chainId
&&
blockNumber
?
getEtherscanLink
(
chainId
,
blockNumber
.
toString
(),
'
block
'
)
:
''
}
>
<
StyledPolling
>
<
StyledPolling
onMouseEnter=
{
()
=>
setIsHover
(
true
)
}
onMouseLeave=
{
()
=>
setIsHover
(
false
)
}
>
<
TYPE
.
small
style=
{
{
opacity
:
isMounted
?
'
0.2
'
:
'
0.6
'
}
}
>
{
blockNumber
}
</
TYPE
.
small
>
<
StyledPollingNumber
breathe=
{
isMounting
}
hovering=
{
isHover
}
>
<
StyledPollingDot
>
{
!
isMounted
&&
<
Spinner
/>
}
</
StyledPollingDot
>
{
blockNumber
}
</
StyledPollingNumber
>
<
StyledPollingDot
>
{
isMounting
&&
<
Spinner
/>
}
</
StyledPollingDot
>
</
StyledPolling
>
</
StyledPolling
>
</
ExternalLink
>
</
ExternalLink
>
)
)
...
...
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