Created
January 10, 2018 10:25
-
-
Save xavxyz/19291b66c17829d36c57db1ae9c92378 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 opticalGradient = [ | |
// bottom left rectangle | |
{x: 0, y: 60, start: 0.5, end: 0 }, | |
// top left rectangle | |
{x: 0, y: 0, start: 0.5, end: 0.75 }, | |
// top right rectangle | |
{x: 60, y: 0, start: 0.75, end: 0.9 }, | |
// bottom right rectangle | |
{x: 60, y: 60, start: 0.9, end: 1 }, | |
]; | |
const OpticalGradient = props => { | |
return props.definitions.map( | |
({ x, y, start, end }) => [ | |
<linearGradient id={`gradient-${x}-${y}`} key="gradient"> | |
<stop offset="0%" stopColor="#FFF" stopOpacity={start} /> | |
<stop offset="100%" stopColor="#FFF" stopOpacity={end} /> | |
</linearGradient>, | |
<rect | |
key="rectangle" | |
x={x} | |
y={y} | |
width={60} | |
height={60} | |
fill={`url(#gradient-${x}-${y})`} | |
/> | |
] | |
); | |
}; | |
const LoadingSpinner = () => { | |
return ( | |
<svg> | |
{/* outer circle */} | |
<OpticalGradient definitions={definitions} /> | |
{/* arc */} | |
</svg> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@xavcz Thank you for the great article!
I noticed a small typo. I think that
line 35
should read: