Last active
November 26, 2019 15:43
-
-
Save tj/fe0ccd4a994d73acea375024fc962af9 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
import React from 'react' | |
const bgStyles = { | |
strokeWidth: 3, | |
strokeLinejoin: 'round', | |
strokeLinecap: 'round', | |
fill: 'none', | |
stroke: '#c3fdff' | |
} | |
const fgStyles = { | |
strokeWidth: 1, | |
strokeLinejoin: 'round', | |
strokeLinecap: 'round', | |
fill: 'none', | |
stroke: '#6CDADE' | |
} | |
function spline(a, b, n = 50) { | |
return `M${a.x},${a.y} C${a.x + n},${a.y} ${b.x - n},${b.y} ${b.x},${b.y}` | |
} | |
export default function Connection({ from, to }) { | |
return <g> | |
<path d={spline(from, to)} style={bgStyles} /> | |
<path d={spline(from, to)} style={fgStyles} /> | |
</g> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment