Skip to content

Commit e3413b4

Browse files
committed
New test/build system
1 parent 1790188 commit e3413b4

18 files changed

+4164
-263
lines changed

.babelrc

-10
This file was deleted.

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
lib
1+
node_modules
2+
3+
cjs
4+
esm
25
umd

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ node_js:
44
branches:
55
only:
66
- master
7-
- /^greenkeeper-/

README.md

+14-9
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
[npm-badge]: https://img.shields.io/npm/v/react-point.svg?style=flat-square
77
[npm]: https://www.npmjs.org/package/react-point
88

9-
[`react-point`](https://www.npmjs.com/package/react-point) is a small, focused click/tap component for React.
9+
[`react-point`](https://www.npmjs.com/package/react-point) gives you fast touch events for your React applications.
1010

11-
A `<PointTarget>` normalizes click and click-like touch events (not swipes or drags) into a "point event". This helps you avoid the 300ms delay for click events on touch interfaces like iOS.
11+
A `<PointTarget>` normalizes click and click-like touch events (not swipes or drags) into a "point" event. This helps you avoid the 300ms delay for click events on touch interfaces like iOS.
1212

1313
## Installation
1414

15-
Using [npm](https://www.npmjs.com/):
15+
Using [yarn](https://yarnpkg.com/):
1616

17-
$ npm install --save react-point
17+
$ yarn add react-point
1818

19-
Then with a module bundler like [webpack](https://webpack.github.io/), use as you would anything else:
19+
Then, use as you would anything else:
2020

2121
```js
2222
// using ES6 modules
@@ -43,7 +43,7 @@ import React from 'react'
4343
import PointTarget from 'react-point'
4444

4545
class App extends React.Component {
46-
handlePoint() {
46+
handlePoint = () => {
4747
alert('I was clicked or tapped!')
4848
}
4949

@@ -55,14 +55,14 @@ class App extends React.Component {
5555
}
5656
```
5757

58-
By default, a `<PointTarget>` renders a `<button>` for accessibility. However, you can use the [`children` prop](https://facebook.github.io/react/tips/children-props-type.html) to make it render something else. For example, to render a `<div>`:
58+
By default, a `<PointTarget>` renders a `<button>` for accessibility. However, you can use the [`children` prop](https://facebook.github.io/react/docs/jsx-in-depth.html#children-in-jsx) to make it render something else. For example, to render a `<div>`:
5959

6060
```js
6161
import React from 'react'
6262
import PointTarget from 'react-point'
6363

6464
class App extends React.Component {
65-
handlePoint() {
65+
handlePoint = () => {
6666
alert('I was clicked or tapped!')
6767
}
6868

@@ -78,4 +78,9 @@ class App extends React.Component {
7878

7979
*Note:* The `onClick`, `onTouchStart`, `onTouchMove`, `onTouchEnd`, and `onTouchCancel` props will be overwritten because `<PointTarget>` needs them to do its thing).
8080

81-
That's it :) Enjoy!
81+
Enjoy!
82+
83+
## About
84+
85+
react-point is developed and maintained by [React Training](https://reacttraining.com). If you're interested in learning more about what React can do for your company, please [get in touch](mailto:[email protected])!
86+
"hat's it :) Enjoy!

karma.conf.js

-113
This file was deleted.

modules/.babelrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": [
3+
[ "es2015", { "loose": true } ],
4+
"stage-1",
5+
"react"
6+
]
7+
}

.eslintrc modules/.eslintrc

-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,5 @@
1515
"rules": {
1616
"array-bracket-spacing": [ 2, "always" ],
1717
"semi": [ 2, "never" ]
18-
},
19-
"globals": {
20-
"__DEV__": true
2118
}
2219
}

modules/PointTarget.js

+16-18
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ const touchY = (event) =>
88
event.touches[0].clientY
99

1010
class PointTarget extends React.Component {
11+
static propTypes = {
12+
children: PropTypes.node,
13+
tolerance: PropTypes.number,
14+
onPoint: PropTypes.func
15+
}
16+
1117
static defaultProps = {
1218
tolerance: 10
1319
}
@@ -16,20 +22,20 @@ class PointTarget extends React.Component {
1622
if (!this.usingTouch && this.props.onPoint)
1723
this.props.onPoint()
1824
}
19-
25+
2026
handleTouchStart = (event) => {
2127
this.usingTouch = true
22-
28+
2329
if (this.touchStarted)
2430
return
25-
31+
2632
this.touchStarted = true
27-
33+
2834
this.touchMoved = false
2935
this.startX = touchX(event)
3036
this.startY = touchY(event)
3137
}
32-
38+
3339
handleTouchMove = (event) => {
3440
if (!this.touchMoved) {
3541
const { tolerance } = this.props
@@ -38,23 +44,23 @@ class PointTarget extends React.Component {
3844
Math.abs(this.startY - touchY(event)) > tolerance
3945
}
4046
}
41-
47+
4248
handleTouchCancel = () => {
4349
this.touchStarted = this.touchMoved = false
4450
this.startX = this.startY = 0
4551
}
46-
52+
4753
handleTouchEnd = () => {
4854
this.touchStarted = false
49-
55+
5056
if (!this.touchMoved && this.props.onPoint)
5157
this.props.onPoint()
5258
}
53-
59+
5460
componentWillMount() {
5561
this.usingTouch = false
5662
}
57-
63+
5864
render() {
5965
const { children } = this.props
6066

@@ -70,12 +76,4 @@ class PointTarget extends React.Component {
7076
}
7177
}
7278

73-
if (__DEV__) {
74-
PointTarget.propTypes = {
75-
children: PropTypes.node,
76-
tolerance: PropTypes.number,
77-
onPoint: PropTypes.func
78-
}
79-
}
80-
8179
export default PointTarget

modules/__tests__/.eslintrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
2+
"plugins": [
3+
"jest"
4+
],
25
"env": {
3-
"mocha": true
6+
"jest/globals": true
47
}
58
}

modules/__tests__/PointTarget-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ describe('A <PointTarget>', () => {
1818
describe('with no children', () => {
1919
it('renders a button', () => {
2020
render(<PointTarget/>, node, () => {
21-
expect(node.firstChild.tagName).toEqual('BUTTON')
21+
expect(node.firstChild.tagName.toLowerCase()).toEqual('button')
2222
})
2323
})
2424
})
2525

2626
describe('with children', () => {
2727
it('renders them', () => {
2828
render(<PointTarget><div/></PointTarget>, node, () => {
29-
expect(node.firstChild.tagName).toEqual('DIV')
29+
expect(node.firstChild.tagName.toLowerCase()).toEqual('div')
3030
})
3131
})
3232
})

modules/index.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
/* eslint-env node */
2-
import PointTarget from './PointTarget'
3-
4-
// TODO: Remove in next major release.
5-
PointTarget.PointTarget = PointTarget
6-
7-
module.exports = PointTarget
1+
export default from './PointTarget'

0 commit comments

Comments
 (0)