Created
April 6, 2017 12:27
-
-
Save knowbody/578b35164b69e867ed4913423f6bed30 to your computer and use it in GitHub Desktop.
Spinner - using styled-components
This file contains hidden or 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
import React from 'react'; | |
import styled from 'styled-components'; | |
const Spinner = () => ( | |
<StyledSpinner viewBox="0 0 50 50"> | |
<circle | |
className="path" | |
cx="25" | |
cy="25" | |
r="20" | |
fill="none" | |
strokeWidth="4" | |
/> | |
</StyledSpinner> | |
); | |
const StyledSpinner = styled.svg` | |
animation: rotate 2s linear infinite; | |
margin: -25px 0 0 -25px; | |
width: 50px; | |
height: 50px; | |
& .path { | |
stroke: #5652BF; | |
stroke-linecap: round; | |
animation: dash 1.5s ease-in-out infinite; | |
} | |
@keyframes rotate { | |
100% { | |
transform: rotate(360deg); | |
} | |
} | |
@keyframes dash { | |
0% { | |
stroke-dasharray: 1, 150; | |
stroke-dashoffset: 0; | |
} | |
50% { | |
stroke-dasharray: 90, 150; | |
stroke-dashoffset: -35; | |
} | |
100% { | |
stroke-dasharray: 90, 150; | |
stroke-dashoffset: -124; | |
} | |
} | |
`; | |
export default Spinner; |
Thanks bro! Helped me
Happy it helped! ππ»
Thank you! It helped me a lot π
Awesome
Perfect, thanks :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you bro! works perfectly