Skip to content

Commit

Permalink
add useclickaway to main artifak pkg, update useclickaway readme
Browse files Browse the repository at this point in the history
  • Loading branch information
heyjul3s committed Mar 29, 2021
1 parent 1f91531 commit fc116d6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/artifak/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@artifak/pxtorem": "^1.0.1",
"@artifak/text-input": "^1.0.2",
"@artifak/typography": "^2.0.0",
"@artifak/useclickaway": "^1.0.0",
"@artifak/usedebouncedfn": "^1.0.0",
"@artifak/usematchmedia": "^1.0.2",
"@artifak/usewindowsize": "^1.0.2"
Expand Down
26 changes: 22 additions & 4 deletions packages/useclickaway/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
# `@artifak/useclickaway`

> TODO: description
A React hook to trigger a callback when a click event occurs on a target that is not the specified ref HTML element.

## Usage

```
const useclickaway = require('@artifak/useclickaway');
```ts
import React from 'react';
import { useClickAway } from '@artifak/useclickaway;

const Dummy = () => {
const ref: React.RefObject<HTMLDivElement> = React.createRef();

const onClickAway = () => {
console.log('Clicked');
};

useClickAway(ref, onClickAway);

// TODO: DEMONSTRATE API
return (
<div>
Wrapper
<div ref={ref}>
Click Me
</div>
</div>
);
};
```

0 comments on commit fc116d6

Please sign in to comment.