-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add icons * feat: add update button component * feat: update network provider * feat: add new button to header * feat: remove loader fetching data * fix: timeout
- Loading branch information
Showing
7 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.update-button { | ||
position: absolute; | ||
top: 17px; | ||
right: 216px; | ||
display: flex; | ||
width: 30px; | ||
height: 30px; | ||
padding: 0; | ||
} | ||
|
||
.update-button svg { | ||
width: 100%; | ||
height: 100%; | ||
fill: rgb(var(--color-green)); | ||
} | ||
|
||
.update-button svg path { | ||
fill: rgb(var(--color-green)); | ||
} | ||
|
||
|
||
@keyframes spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
.loading-animated { | ||
animation: spin 2s linear infinite; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useState, useContext, useEffect } from 'react' | ||
|
||
import { Button } from '@BasicComponents' | ||
import { ReactComponent as SuccessImg } from '@Assets/images/icon-success.svg' | ||
import { ReactComponent as LoadingImg } from '@Assets/images/icon-loading.svg' | ||
|
||
import { NetworkContext } from '@Contexts' | ||
|
||
import './UpdateButton.css' | ||
|
||
|
||
const UpdateButton = () => { | ||
const { fetchAllData, fetchDelegations } = | ||
useContext(NetworkContext) | ||
const [loading, setLoading] = useState(false) | ||
const [showSuccess, setShowSuccess] = useState(false) | ||
|
||
const handleClick = async () => { | ||
try { | ||
setLoading(true) | ||
await fetchAllData() | ||
await fetchDelegations() | ||
setLoading(false) | ||
setShowSuccess(true) | ||
} | ||
catch (error) { | ||
console.error(error) | ||
setLoading(false) | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
const timeout = setTimeout(() => { | ||
setShowSuccess(false) | ||
}, 3000) | ||
return () => clearTimeout(timeout) | ||
}, [showSuccess]) | ||
|
||
return ( | ||
<Button | ||
onClickHandle={handleClick} | ||
className="update-button" | ||
alternate | ||
extraStyleClasses={['update-button']} | ||
> | ||
{loading && <LoadingImg className="loading-animated" />} | ||
{!loading && showSuccess && <SuccessImg />} | ||
{!loading && !showSuccess && <LoadingImg />} | ||
</Button> | ||
) | ||
} | ||
|
||
export default UpdateButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters