-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from hshoff/harry-refs
[shape] add innerRef prop to shapes. fixes #140
- Loading branch information
Showing
15 changed files
with
239 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
import React from 'react'; | ||
import cx from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
import { linkHorizontal } from 'd3-shape'; | ||
import additionalProps from '../util/additionalProps'; | ||
|
||
LinkHorizontal.propTypes = { | ||
innerRef: PropTypes.func, | ||
}; | ||
|
||
export default function LinkHorizontal({ | ||
className, | ||
innerRef, | ||
data, | ||
x = d => d.y, | ||
y = d => d.x, | ||
...restProps | ||
}) { | ||
const link = linkHorizontal() | ||
const link = linkHorizontal(); | ||
link.x(x); | ||
link.y(y); | ||
return ( | ||
<path | ||
ref={innerRef} | ||
className={cx('vx-link-horizontal', className)} | ||
d={link(data)} | ||
{...additionalProps(restProps, data)} | ||
/> | ||
); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
import React from 'react'; | ||
import cx from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
import { linkVertical } from 'd3-shape'; | ||
import additionalProps from '../util/additionalProps'; | ||
|
||
LinkVertical.propTypes = { | ||
innerRef: PropTypes.func, | ||
}; | ||
|
||
export default function LinkVertical({ | ||
className, | ||
innerRef, | ||
data, | ||
x = d => d.x, | ||
y = d => d.y, | ||
...restProps | ||
}) { | ||
const link = linkVertical() | ||
const link = linkVertical(); | ||
link.x(x); | ||
link.y(y); | ||
return ( | ||
<path | ||
ref={innerRef} | ||
className={cx('vx-link-vertical', className)} | ||
d={link(data)} | ||
{...additionalProps(restProps, data)} | ||
/> | ||
); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { Bar } from '../src'; | ||
|
||
describe('<Bar />', () => { | ||
test('it should be defined', () => { | ||
expect(Bar).toBeDefined() | ||
}) | ||
}) | ||
expect(Bar).toBeDefined(); | ||
}); | ||
|
||
test('it should expose its ref via an innerRef prop', done => { | ||
const node = document.createElement('div'); | ||
const refCallback = n => { | ||
expect(n.tagName).toEqual('RECT'); | ||
done(); | ||
}; | ||
ReactDOM.render(<Bar innerRef={refCallback} />, node); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
import React from "react"; | ||
import { shallow } from "enzyme"; | ||
import { Line } from "../src"; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { shallow } from 'enzyme'; | ||
import { Line } from '../src'; | ||
|
||
const LineWrapper = ({ ...restProps }) => shallow(<Line {...restProps} />); | ||
const LineWrapper = ({ ...restProps }) => | ||
shallow(<Line {...restProps} />); | ||
|
||
describe("<Line />", () => { | ||
test("it should be defined", () => { | ||
describe('<Line />', () => { | ||
test('it should be defined', () => { | ||
expect(Line).toBeDefined(); | ||
}); | ||
|
||
test("it should contain a <line/>", () => { | ||
expect(LineWrapper().find("line").length).toBe(1); | ||
test('it should contain a <line/>', () => { | ||
expect(LineWrapper().find('line').length).toBe(1); | ||
}); | ||
|
||
test("it should have the .vx-line class", () => { | ||
expect(LineWrapper().prop("className")).toBe("vx-line"); | ||
test('it should have the .vx-line class', () => { | ||
expect(LineWrapper().prop('className')).toBe('vx-line'); | ||
}); | ||
|
||
test('it should expose its ref via an innerRef prop', done => { | ||
const node = document.createElement('div'); | ||
const refCallback = n => { | ||
expect(n.tagName).toEqual('LINE'); | ||
done(); | ||
}; | ||
ReactDOM.render(<Line innerRef={refCallback} />, node); | ||
}); | ||
}); |
Oops, something went wrong.