Skip to content

Commit

Permalink
fix(vx-shape): path => pathGen, remove duplicate number type
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Williams committed Oct 9, 2019
1 parent 138353f commit d5cee59
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/Area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type AreaProps<Datum> = {
/** React RefObject passed to the path element. */
innerRef?: React.Ref<SVGPathElement>;
/** Sets the x0 accessor function, and sets x1 to null. */
x?: NumberAccessor<Datum> | number | number;
x?: NumberAccessor<Datum> | number;
/** Specifies the x0 accessor function which defaults to d => d[0]. */
x0?: NumberAccessor<Datum> | number;
/** Specifies the x1 accessor function which defaults to null. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function LinkHorizontalCurve<Link, Node>({
}: LinkHorizontalCurveProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkHorizontalCurveProps<Link, Node>>) {
const pathGen = path || pathHorizontalCurve({ source, target, x, y, percent });
if (children) return <>{children({ path })}</>;
if (children) return <>{children({ path: pathGen })}</>;
return (
<path
ref={innerRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function LinkRadialCurve<Link, Node>({
}: LinkRadialCurveProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkRadialCurveProps<Link, Node>>) {
const pathGen = path || pathRadialCurve({ source, target, x, y, percent });
if (children) return <>{children({ path })}</>;
if (children) return <>{children({ path: pathGen })}</>;
return (
<path
ref={innerRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function LinkVerticalCurve<Link, Node>({
}: LinkVerticalCurveProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkVerticalCurveProps<Link, Node>>) {
const pathGen = path || pathVerticalCurve({ source, target, x, y, percent });
if (children) return <>{children({ path })}</>;
if (children) return <>{children({ path: pathGen })}</>;
return (
<path
ref={innerRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function LinkHorizontalDiagonal<Link, Node>({
}: LinkHorizontalDiagonalProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkHorizontalDiagonalProps<Link, Node>>) {
const pathGen = path || pathHorizontalDiagonal({ source, target, x, y });
if (children) return <>{children({ path })}</>;
if (children) return <>{children({ path: pathGen })}</>;
return (
<path
ref={innerRef}
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/link/diagonal/LinkRadial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function LinkRadialDiagonal<Link, Node>({
}: LinkRadialDiagonalProps<Node, Link> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkRadialDiagonalProps<Link, Node>>) {
const pathGen = path || pathRadialDiagonal({ source, target, angle, radius });
if (children) return <>{children({ path })}</>;
if (children) return <>{children({ path: pathGen })}</>;
return (
<path
ref={innerRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function LinkVerticalDiagonal<Link, Node>({
}: LinkVerticalDiagonalProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkVerticalDiagonalProps<Link, Node>>) {
const pathGen = path || pathVerticalDiagonal({ source, target, x, y });
if (children) return <>{children({ path })}</>;
if (children) return <>{children({ path: pathGen })}</>;
return (
<path
ref={innerRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function LinkHorizontalLine<Link, Node>({
}: LinkHorizontalLineProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkHorizontalLineProps<Link, Node>>) {
const pathGen = path || pathHorizontalLine({ source, target, x, y });
if (children) return <>{children({ path })}</>;
if (children) return <>{children({ path: pathGen })}</>;
return (
<path
ref={innerRef}
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/link/line/LinkRadialLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function LinkRadialLine<Link, Node>({
}: LinkRadialLineProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkRadialLineProps<Link, Node>>) {
const pathGen = path || pathRadialLine({ source, target, x, y });
if (children) return <>{children({ path })}</>;
if (children) return <>{children({ path: pathGen })}</>;
return (
<path
ref={innerRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function LinkVerticalLine<Link, Node>({
}: LinkVerticalLineProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkVerticalLineProps<Link, Node>>) {
const pathGen = path || pathVerticalLine({ source, target, x, y });
if (children) return <>{children({ path })}</>;
if (children) return <>{children({ path: pathGen })}</>;
return (
<path
ref={innerRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function LinkHorizontalStep<Link, Node>({
}: LinkHorizontalStepProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkHorizontalStepProps<Link, Node>>) {
const pathGen = path || pathHorizontalStep({ source, target, x, y, percent });
if (children) return <>{children({ path })}</>;
if (children) return <>{children({ path: pathGen })}</>;
return (
<path
ref={innerRef}
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/link/step/LinkRadialStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function LinkRadialStep<Link, Node>({
}: LinkRadialStepProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkRadialStepProps<Link, Node>>) {
const pathGen = path || pathRadialStep({ source, target, x, y });
if (children) return <>{children({ path })}</>;
if (children) return <>{children({ path: pathGen })}</>;
return (
<path
ref={innerRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function LinkVerticalStep<Link, Node>({
}: LinkVerticalStepProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkVerticalStepProps<Link, Node>>) {
const pathGen = path || pathVerticalStep({ source, target, x, y, percent });
if (children) return <>{children({ path })}</>;
if (children) return <>{children({ path: pathGen })}</>;
return (
<path
ref={innerRef}
Expand Down
4 changes: 2 additions & 2 deletions packages/vx-shape/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ export type SharedLinkProps<Link> = {
/** React ref to the path element. */
innerRef?: React.Ref<SVGPathElement>;
/** Path generator, given a link returns a path d attribute string */
path: PathType<Link>;
path?: PathType<Link>;
/** Render function override which is passed the configured path generator as input. */
children?: (args: { path: PathType<Link> }) => NonNullable<React.ReactNode>;
children?: (args: { path: PathType<Link> }) => React.ReactNode;
/** Datum for which to render a link. */
data: Link;
};
Expand Down

0 comments on commit d5cee59

Please sign in to comment.