Skip to content

Instantly share code, notes, and snippets.

@beshanoe
Forked from knowbody/Spinner.js
Created August 7, 2017 14:07
Show Gist options
  • Save beshanoe/bb6e61544bfcc7af01100712522c444c to your computer and use it in GitHub Desktop.
Save beshanoe/bb6e61544bfcc7af01100712522c444c to your computer and use it in GitHub Desktop.
Spinner - using styled-components
import React from 'react';
import styled from 'styled-components';
const rotate = keyframes`
100% {
transform: rotate(360deg);
}
`
const dash = keyframes`
0% {
stroke-dasharray: 1, 150;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 90, 150;
stroke-dashoffset: -35;
}
100% {
stroke-dasharray: 90, 150;
stroke-dashoffset: -124;
}
`
const StyledSpinner = styled.svg`
animation: ${rotate} 2s linear infinite;
width: 100px;
height: 100px;
& .path {
stroke: white;
stroke-linecap: round;
animation: ${dash} 1.5s ease-in-out infinite;
}
`
const Spinner = () =>
<StyledSpinner viewBox="0 0 50 50">
<circle
className="path"
cx="25"
cy="25"
r="20"
fill="none"
strokeWidth="4"
/>
</StyledSpinner>
export default Spinner;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment