Created
January 10, 2018 10:27
-
-
Save xavxyz/a2d8d09b5deacf3887a94a78b29e53d7 to your computer and use it in GitHub Desktop.
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
const animation = 'spin 1.6s linear infinite'; | |
const OpticalGradient = props => { | |
return props.definitions.map( | |
({ x, y, start, end }) => [ | |
/* linear gradient */ | |
<rect | |
key="rectangle" | |
x={x} | |
y={y} | |
width={60} | |
height={60} | |
fill={`url(#gradient-${x}-${y})`} | |
// the style prop is an object | |
style={{ animation }} | |
/> | |
] | |
); | |
}; | |
const LoadingSpinner = () => { | |
return ( | |
<svg viewBox="0 0 120 120" fill="transparent"> | |
{/* | |
other elements | |
*/} | |
<circle | |
r={36} | |
cx={60} | |
cy={60} | |
fill="transparent" | |
stroke="url(#arc-gradient)" | |
strokeWidth={2} | |
// we re-use the animation defined above, | |
// make it turn in the opposite direction | |
// and add a small delay to make it start before the opacity layer | |
style={{ animation: `${animation} reverse -0.2s`}} | |
/> | |
</svg> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment