-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support gradient #1
base: master
Are you sure you want to change the base?
Conversation
getLinkColor(): string[] | string | undefined| null { | ||
const { linkData, pathColorFunc } = this.props; | ||
let color = pathColorFunc; | ||
if (typeof pathColorFunc === 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the support for non-function here - just always call pathColorFunc
(also the Props typing says its always a function)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to check if pathColorFunc is a function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? In TypeScript we shouldn't verify, we depend on the using code to have TypeScript as well, or to be responsible. See other function props above - they don't verify them.
src/Link/index.tsx
Outdated
data-target-id={linkData.target.id} | ||
/> | ||
<> | ||
{gradientStartColor && <defs> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider extracting this to a method to be used like this {this.getGradientDef(gradientStartColor, gradientEndColor)
(linkData
can be extracted from the props inside getGradientDef
)
src/Link/index.tsx
Outdated
/> | ||
<> | ||
{gradientStartColor && <defs> | ||
<linearGradient x1={linkData.source.x} y1={linkData.source.y} x2={linkData.target.x} y2={linkData.target.y} id={gradientId} gradientUnits="userStepOnUse"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an invalid value for gradientUnits
, you mean userSpaceOnUse
:
<linearGradient x1={linkData.source.x} y1={linkData.source.y} x2={linkData.target.x} y2={linkData.target.y} id={gradientId} gradientUnits="userStepOnUse"> | |
<linearGradient x1={linkData.source.x} y1={linkData.source.y} x2={linkData.target.x} y2={linkData.target.y} id={gradientId} gradientUnits="userSpaceOnUse"> |
No description provided.