Skip to content

Commit 6404037

Browse files
committedJan 21, 2019
Add README and LICENSE
1 parent 038677a commit 6404037

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
 

‎LICENSE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2019 Andrew Branch
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

‎README.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# react-use-hover
2+
3+
A React state hook to determine whether a React element is being hovered.
4+
5+
## Installation
6+
7+
```
8+
npm install react-use-hover
9+
```
10+
11+
## Usage
12+
13+
```js
14+
import useHover from 'react-use-hover';
15+
16+
function Tooltip() {
17+
const [isHovering, hoverProps] = useHover();
18+
return (
19+
<>
20+
<span {...hoverProps} aria-describedby="overlay">Hover me</span>
21+
<Overlay visible={isHovering} role="tooltip" id="overlay">
22+
I’m a lil popup or something!
23+
</Overlay>
24+
</>
25+
);
26+
}
27+
```
28+
29+
### Options
30+
31+
```js
32+
useHover({
33+
mouseEnterDelayMS,
34+
mouseLeaveDelayMS
35+
})
36+
```
37+
38+
- **`mouseEnterDelayMS: number = 200`**. The number of milliseconds to delay before setting the `isHovering` state to `true`. (Mousing back out during this delay period will cancel the state change.)
39+
- **`mouseLeaveDelayMS: number = 0`**. The number of milliseconds to delay before setting the `isHovering` state to `false`. (Mousing back in during this period will cancel the state change.)
40+
41+
## Testing
42+
43+
```bash
44+
# Run once, with coverage
45+
npm run test
46+
47+
# Watch mode
48+
npm run test -- --watch
49+
50+
# Do whatever you want
51+
npx jest # --any --jest --options
52+
```
53+
54+
## Contributing
55+
56+
PRs welcome! Please ensure you `npm run build` and commit before pushing (to run prettier) and maintain 100% test coverage.

0 commit comments

Comments
 (0)
Please sign in to comment.