Skip to content

Commit

Permalink
Add demo app
Browse files Browse the repository at this point in the history
  • Loading branch information
rafgraph committed Feb 12, 2021
1 parent 8dfd547 commit 5c1f625
Show file tree
Hide file tree
Showing 26 changed files with 42,012 additions and 8 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Event From

[![npm bundle size (version)](https://img.shields.io/bundlephobia/minzip/event-from?color=purple)](https://bundlephobia.com/result?p=event-from) ![npm type definitions](https://img.shields.io/npm/types/event-from?color=blue)

Determine if a browser event was caused by `mouse`, `touch`, or `key` input. Can be used to:

- Ignore `mouse` events caused by `touch` input.
- Determine if `focus` was initiated from the keyboard (to know when to add focus styles).
- Determining if a `click` event was from `mouse`, `touch`, or `key` input.
- And anything else where knowing the type of user interaction that generated the event is helpful.
- You may also be interested in [Detect It](https://github.com/rafgraph/detect-it), which detects if a device is `mouseOnly`, `touchOnly`, or `hybrid`, and if the primary input is `mouse` or `touch`.

[![npm bundle size (version)](https://img.shields.io/bundlephobia/minzip/event-from?color=purple)](https://bundlephobia.com/result?p=event-from) ![npm type definitions](https://img.shields.io/npm/types/event-from?color=blue)

---

[Demo website](https://event-from.rafgraph.dev) (code in the [demo repo](https://github.com/rafgraph/event-from-demo))
**[Live demo app](https://event-from.rafgraph.dev)**, code in the `/demo` folder

---

Expand Down Expand Up @@ -51,14 +50,14 @@ element.addEventListener('mouseenter', handleMouseEvent, false);

---

### Determine if a `focus` event was from `key` input for accessibility
### Determine if a `focus` event was from `key` input to add focus styles

```js
import { eventFrom } from 'event-from';

const handleFocusEvent = (e) => {
if (eventFrom(e) === 'key') {
// set focus styles when focus is from keyboard input
// add focus styles when focus is from keyboard input
}
};

Expand Down Expand Up @@ -102,7 +101,7 @@ import { eventFrom, setEventFrom } from 'event-from';

const handleFocusEvent = (e) => {
if (eventFrom(e) === 'key') {
// set focus styles when focus is from keyboard input
// add focus styles when focus is from keyboard input
}
};

Expand Down
1 change: 1 addition & 0 deletions demo/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP_PREFLIGHT_CHECK=true
24 changes: 24 additions & 0 deletions demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.eslintcache

npm-debug.log*
yarn-debug.log*
yarn-error.log*
21 changes: 21 additions & 0 deletions demo/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Rafael Pedicini

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:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

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.
3 changes: 3 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Demo App for [`event-from`](https://github.com/rafgraph/event-from)

Live demo app: https://event-from.rafgraph.dev
Loading

0 comments on commit 5c1f625

Please sign in to comment.