-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 #189 from streamich/next
Next
- Loading branch information
Showing
42 changed files
with
1,245 additions
and
271 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 |
---|---|---|
|
@@ -55,6 +55,27 @@ jobs: | |
path: ~/repo/storybook-static | ||
- *Commit_Status_Storybook | ||
|
||
next: | ||
<<: *container | ||
steps: | ||
- checkout | ||
- *Versions | ||
- *Install | ||
- *Build | ||
- *Build_Storybook | ||
- *Test | ||
- store_artifacts: | ||
path: ~/repo/storybook-static | ||
- *Commit_Status_Storybook | ||
- run: | ||
name: Setup GitHub | ||
command: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "streamich" | ||
git remote rm origin | ||
git remote add origin https://${GITHUB_TOKEN}@github.com/streamich/react-use | ||
- *Release | ||
|
||
master: | ||
<<: *container | ||
steps: | ||
|
@@ -87,7 +108,15 @@ workflows: | |
branches: | ||
ignore: | ||
- master | ||
- next | ||
- gh-pages | ||
next: | ||
jobs: | ||
- next: | ||
context: common-env-vars | ||
filters: | ||
branches: | ||
only: next | ||
master: | ||
jobs: | ||
- master: | ||
|
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# `useDrop` and `useDropArea` | ||
|
||
Triggers on file, link drop and copy-paste. | ||
|
||
`useDrop` tracks events for the whole page, `useDropArea` tracks drop events | ||
for a specific element. | ||
|
||
|
||
## Usage | ||
|
||
`useDrop`: | ||
|
||
```jsx | ||
import {useDrop} from 'react-use'; | ||
|
||
const Demo = () => { | ||
const state = useDrop({ | ||
onFiles: files => console.log('files', files), | ||
onUri: uri => console.log('uri', uri), | ||
onText: text => console.log('text', text), | ||
}); | ||
|
||
return ( | ||
<div> | ||
Drop something on the page. | ||
</div> | ||
); | ||
}; | ||
``` | ||
|
||
`useDropArea`: | ||
|
||
```jsx | ||
import {useDropArea} from 'react-use'; | ||
|
||
const Demo = () => { | ||
const [bond, state] = useDropArea({ | ||
onFiles: files => console.log('files', files), | ||
onUri: uri => console.log('uri', uri), | ||
onText: text => console.log('text', text), | ||
}); | ||
|
||
return ( | ||
<div {...bond}> | ||
Drop something here. | ||
</div> | ||
); | ||
}; | ||
``` |
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,38 @@ | ||
# `useEvent` | ||
|
||
React sensor hook that subscribes a `handler` to events. | ||
|
||
|
||
## Usage | ||
|
||
```jsx | ||
import useEvent from 'react-use/lib/useEvent'; | ||
import useList from 'react-use/lib/useList'; | ||
|
||
const Demo = () => { | ||
const [list, {push}] = useList(); | ||
const onkeydown = ({key}) => { | ||
push(key); | ||
}; | ||
useEvent('keydown', useCallback(onkeydown, [])); | ||
|
||
return ( | ||
<div> | ||
<p> | ||
Press some keys on your keyboard. | ||
</p> | ||
<pre> | ||
{JSON.stringify(list, null, 4)} | ||
</pre> | ||
</div> | ||
); | ||
}; | ||
``` | ||
|
||
|
||
## Examples | ||
|
||
```js | ||
useEvent('keydown', handler) | ||
useEvent('scroll', handler, window, {capture: true}) | ||
``` |
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,30 @@ | ||
# `useFullscreen` | ||
|
||
Display an element full-screen, optional fallback for fullscreen video on iOS. | ||
|
||
## Usage | ||
|
||
```jsx | ||
import useFullscreen from 'react-use/lib/useFullscreen'; | ||
import useToggle from 'react-use/lib/useToggle'; | ||
|
||
const Demo = () => { | ||
const ref = useRef(null) | ||
const [show, toggle] = useToggle(false); | ||
const isFullscreen = useFullscreen(ref, show, {onClose: () => toggle(false)}); | ||
|
||
return ( | ||
<div ref={ref} style={{backgroundColor: 'white'}}> | ||
<div>{isFullscreen ? 'Fullscreen' : 'Not fullscreen'}</div> | ||
<button onClick={() => toggle()}>Toggle</button> | ||
<video src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" autoPlay /> | ||
</div> | ||
); | ||
}; | ||
``` | ||
|
||
## Reference | ||
|
||
```ts | ||
useFullscreen(ref, show, {onClose}) | ||
``` |
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,46 @@ | ||
# `useKey` | ||
|
||
React UI sensor hook that executes a `handler` when a keyboard key is used. | ||
|
||
## Usage | ||
|
||
```jsx | ||
import useKey from 'react-use/lib/useKey'; | ||
|
||
const Demo = () => { | ||
const [count, set] = useState(0); | ||
const increment = () => set(count => ++count); | ||
useKey('ArrowUp', increment); | ||
|
||
return ( | ||
<div> | ||
Press arrow up: {count} | ||
</div> | ||
); | ||
}; | ||
``` | ||
|
||
Or as render-prop: | ||
|
||
```jsx | ||
import UseKey from 'react-use/lib/comps/UseKey'; | ||
|
||
<UseKey filter='a' fn={() => alert('"a" key pressed!')} /> | ||
``` | ||
|
||
|
||
## Reference | ||
|
||
```js | ||
useKey(filter, handler, options?, deps?) | ||
``` | ||
## Examples | ||
```js | ||
useKey('a', () => alert('"a" pressed')); | ||
|
||
const predicate = (event) => event.key === 'a' | ||
useKey(predicate, handler, {event: 'keyup'}); | ||
``` |
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
Oops, something went wrong.