Skip to content
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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Conversation

avshalomt2
Copy link
Owner

No description provided.

getLinkColor(): string[] | string | undefined| null {
const { linkData, pathColorFunc } = this.props;
let color = pathColorFunc;
if (typeof pathColorFunc === 'function') {
Copy link
Owner Author

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)

Copy link
Collaborator

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

Copy link
Owner Author

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 Show resolved Hide resolved
data-target-id={linkData.target.id}
/>
<>
{gradientStartColor && <defs>
Copy link
Owner Author

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)

/>
<>
{gradientStartColor && <defs>
<linearGradient x1={linkData.source.x} y1={linkData.source.y} x2={linkData.target.x} y2={linkData.target.y} id={gradientId} gradientUnits="userStepOnUse">
Copy link
Owner Author

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:

Suggested change
<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">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants