-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from mathiasayivor/feat-loading-animation
- Loading branch information
Showing
6 changed files
with
192 additions
and
15 deletions.
There are no files selected for viewing
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,11 @@ | ||
import { Button } from "@mui/material"; | ||
import Loader from "./Loader"; | ||
|
||
export default function AnimatedButton(props) { | ||
const { loading, children, ..._props } = props; | ||
return ( | ||
<Button {..._props} disabled={loading}> | ||
{loading ? <Loader /> : children} | ||
</Button> | ||
); | ||
} |
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,93 @@ | ||
/** | ||
* Credits: https://codepen.io/feirer/pen/zovgae | ||
* Patrick Feirer | ||
* | ||
*/ | ||
|
||
body { | ||
background-color: #fbfbfb; | ||
} | ||
|
||
.loader { | ||
box-sizing: border-box; | ||
display: flex; | ||
position: relative; | ||
justify-content: center; | ||
perspective-origin: 60px 60px; | ||
transform-origin: 60px 60px; | ||
border: 0px solid #000000; | ||
flex: 0 0 auto; | ||
flex-flow: column nowrap; | ||
} | ||
|
||
.loader:after, | ||
.loader:before { | ||
height: 100%; | ||
width: 100%; | ||
border-radius: 50%; | ||
border-style: solid; | ||
border-width: 2px; | ||
box-sizing: border-box; | ||
content: ""; | ||
left: 0; | ||
position: absolute; | ||
top: 0; | ||
} | ||
|
||
.loader:after { | ||
-webkit-animation: rotate 1s infinite ease; | ||
animation: rotate 1s infinite ease; | ||
border-color: #3897f0 transparent transparent; | ||
-webkit-transform-origin: 50%; | ||
transform-origin: 50%; | ||
} | ||
|
||
.loader:before { | ||
border-color: #c7c7c7; | ||
} | ||
|
||
.loader a { | ||
display: block; | ||
font-size: 14px; | ||
margin: -60px 0; | ||
padding: 60px 9px; | ||
position: relative; | ||
text-align: center; | ||
vertical-align: middle; | ||
z-index: 1; | ||
color: #c7c7c7; | ||
text-decoration: none; | ||
font: normal normal 600 normal 14px / 14px proxima-nova, "Helvetica Neue", | ||
Arial, Helvetica, sans-serif; | ||
} | ||
|
||
@-webkit-keyframes rotate { | ||
0% { | ||
-webkit-transform: rotate(0deg); | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
-webkit-transform: rotate(360deg); | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
@keyframes rotate { | ||
0% { | ||
-webkit-transform: rotate(0deg); | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
-webkit-transform: rotate(360deg); | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
.note { | ||
color: #c7c7c7; | ||
text-decoration: none; | ||
font: normal normal 600 normal 12px / 12px proxima-nova, "Helvetica Neue", | ||
Arial, Helvetica, sans-serif; | ||
text-align: center; | ||
width: 100%; | ||
} |
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,36 @@ | ||
import "./Loader.css"; | ||
|
||
/** | ||
* | ||
* @param {{ | ||
* width: number, | ||
* height:number | ||
* }} props | ||
*/ | ||
export default function Loader(props) { | ||
const { width, height } = Object.assign( | ||
{ | ||
width: 30, | ||
height: 30, | ||
}, | ||
props | ||
); | ||
|
||
return ( | ||
<div | ||
style={{ | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
}} | ||
> | ||
<div | ||
className="loader" | ||
style={{ | ||
width: `${width}px`, | ||
height: `${height}px`, | ||
}} | ||
/> | ||
</div> | ||
); | ||
} |