-
Notifications
You must be signed in to change notification settings - Fork 730
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 #61 from williaster/chris--clip-path
[ClipPath] add ClipPath package
- Loading branch information
Showing
8 changed files
with
172 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"presets": ["es2015", "react", "stage-0"], | ||
"plugins": [], | ||
"env": { | ||
"development": { | ||
"plugins": [ | ||
["react-transform", { | ||
"transforms": [{ | ||
"transform": "react-transform-hmr", | ||
"imports": ["react"], | ||
"locals": ["module"] | ||
}] | ||
}], | ||
"transform-runtime", | ||
"transform-decorators-legacy" | ||
] | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
include node_modules/react-fatigue-dev/Makefile |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "@vx/clip-path", | ||
"version": "0.0.0", | ||
"description": "vx clip-path", | ||
"main": "build/index.js", | ||
"scripts": { | ||
"build": "make build SRC=./src", | ||
"prepublish": "make build SRC=./src", | ||
"test": "jest" | ||
}, | ||
"files": [ | ||
"build" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/hshoff/vx.git" | ||
}, | ||
"keywords": [ | ||
"vx", | ||
"react", | ||
"d3", | ||
"visualizations", | ||
"charts", | ||
"svg" | ||
], | ||
"author": "Chris Williams @williaster", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/hshoff/vx/issues" | ||
}, | ||
"homepage": "https://github.com/hshoff/vx#readme", | ||
"devDependencies": { | ||
"babel-jest": "^20.0.3", | ||
"enzyme": "^2.8.2", | ||
"jest": "^20.0.3", | ||
"react-addons-test-utils": "15.4.2", | ||
"react-fatigue-dev": "github:tj/react-fatigue-dev", | ||
"react-tools": "^0.10.0", | ||
"regenerator-runtime": "^0.10.5" | ||
}, | ||
"dependencies": { | ||
"react": "15.4.2" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import ClipPath from './ClipPath'; | ||
|
||
export default ({ | ||
id, | ||
cx, | ||
cy, | ||
r, | ||
...restProps, | ||
}) => ( | ||
<ClipPath id={id}> | ||
<circle | ||
cx={cx} | ||
cy={cy} | ||
r={r} | ||
{...restProps} | ||
/> | ||
</ClipPath> | ||
); | ||
|
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
|
||
export default ({ | ||
id, | ||
children, | ||
...restProps | ||
}) => ( | ||
<defs> | ||
<clipPath id={id} {...restProps}> | ||
{children} | ||
</clipPath> | ||
</defs> | ||
); |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import ClipPath from './ClipPath'; | ||
|
||
export default ({ | ||
id, | ||
x = 0, | ||
y = 0, | ||
width = 1, | ||
height = 1, | ||
...restProps, | ||
}) => ( | ||
<ClipPath id={id}> | ||
<rect | ||
x={x} | ||
y={y} | ||
width={width} | ||
height={height} | ||
{...restProps} | ||
/> | ||
</ClipPath> | ||
); |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default as ClipPath } from './clip-paths/ClipPath'; | ||
export { default as CircleClipPath } from './clip-paths/CircleClipPath'; | ||
export { default as RectClipPath } from './clip-paths/RectClipPath'; |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
ClipPath, | ||
CircleClipPath, | ||
RectClipPath, | ||
} from '../src'; | ||
|
||
import { shallow } from 'enzyme'; | ||
|
||
describe('<ClipPath />', () => { | ||
test('it should be defined', () => { | ||
expect(ClipPath).toBeDefined(); | ||
}); | ||
|
||
test('it should render defs and clipPath elements', () => { | ||
const wrapper = shallow(<ClipPath />); | ||
expect(wrapper.type()).toBe('defs'); | ||
expect(wrapper.find('clipPath').length).toBe(1); | ||
}); | ||
|
||
test('it should assign the passed id to the clipPath', () => { | ||
const wrapper = shallow(<ClipPath id="best_clip"/>); | ||
expect(wrapper.find('clipPath#best_clip').length).toBe(1); | ||
}); | ||
}); | ||
|
||
describe('<RectClipPath />', () => { | ||
test('it should be defined', () => { | ||
expect(RectClipPath).toBeDefined(); | ||
}); | ||
|
||
test('it should render a rect', () => { | ||
const wrapper = shallow(<RectClipPath />); | ||
expect(wrapper.find('rect').length).toBe(1); | ||
}); | ||
}); | ||
|
||
describe('<CircleClipPath />', () => { | ||
test('it should be defined', () => { | ||
expect(CircleClipPath).toBeDefined(); | ||
}); | ||
|
||
test('it should render a circle', () => { | ||
const wrapper = shallow(<CircleClipPath />); | ||
expect(wrapper.find('circle').length).toBe(1); | ||
}); | ||
}); |