Skip to content

Instantly share code, notes, and snippets.

@dburles
Created December 10, 2018 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dburles/9ae6df7d19815e5a2ccc908d3fa7dffb to your computer and use it in GitHub Desktop.
Save dburles/9ae6df7d19815e5a2ccc908d3fa7dffb to your computer and use it in GitHub Desktop.
import React from 'react';
import styled from 'styled-components';
const Center = styled.div`
position: fixed;
top: 50%;
left: 50%;
`;
const Spinner = () => (
<Center>
<StyledSpinner viewBox="0 0 50 50">
<circle
className="path"
cx="25"
cy="25"
r="20"
fill="none"
strokeWidth="4"
/>
</StyledSpinner>
</Center>
);
const StyledSpinner = styled.svg`
animation: rotate 2s linear infinite;
margin: -25px 0 0 -25px;
width: 50px;
height: 50px;
& .path {
stroke: ${props => props.theme.colors.darken};
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment