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

[shape] export link path generators, Link* use additonalProps. fixes #263 #265

Merged
merged 1 commit into from
Apr 8, 2018

Conversation

hshoff
Copy link
Member

@hshoff hshoff commented Apr 8, 2018

💥 Breaking Changes

  • [shape] <Link* /> components now use ...additionalProps() everywhere for consistency. So function props get passed data. example: onClick={event => // stuff} becomes onClick={data => event => // stuff} and now you can stroke/fill/attr based on data `stroke={({ target }) => target.data.children ? 'yellow' : 'blue' }

screen shot 2018-04-08 at 2 04 07 pm

🚀 Enhancements

import { LinkVerticalLine, pathVerticalLine } from '@vx/shape';

const path = pathVerticalLine({
  source: d => d.source,
  target: d => d.target,
  x: d => d.x,
  y: d => d.y
});

<LinkVerticalLine
  data={data}
  path={path}
/>

// default usage doesn't change
<LinkVerticalLine
  data={data}
  source={d => d.source}
  target={d => d.target}
  x={d => d.x}
  y={d => d.y}
/>

if you don't pass path prop, then <Link* /> components will create the path generator for you from the provided or defaulted source, target, x, y, percent, etc:

export default function LinkVerticalLine({
  className,
  innerRef,
  data,
  path,
  x = d => d.x,
  y = d => d.y,
  source = d => d.source,
  target = d => d.target,
  ...restProps
}) {
  path = path || pathVerticalLine({ source, target, x, y });
  return (
    <path
      ref={innerRef}
      className={cx('vx-link', className)}
      d={path(data)}
      {...additionalProps(restProps, data)}
    />
  );
}

@hshoff hshoff added this to the v0.0.160 milestone Apr 8, 2018
@hshoff hshoff requested a review from techniq April 8, 2018 18:08
@hshoff hshoff merged commit 03c574d into master Apr 8, 2018
@hshoff hshoff deleted the harry-paths branch April 8, 2018 18:20
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.

Extract path generators from Link* components
1 participant