poltrgeist-react 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +63 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # poltrgeist-react
2
+
3
+ React bindings for [poltrgeist](https://www.npmjs.com/package/poltrgeist) — funny, non-annoying UI/UX effects for any web page.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install poltrgeist poltrgeist-react
9
+ ```
10
+
11
+ Requires React ≥ 17.
12
+
13
+ ## Usage
14
+
15
+ ### `PoltrgeistProvider`
16
+
17
+ Wrap your app to auto-haunt the DOM with probability-based effects.
18
+
19
+ ```tsx
20
+ import { PoltrgeistProvider } from 'poltrgeist-react'
21
+
22
+ function App() {
23
+ return (
24
+ <PoltrgeistProvider options={{ probability: 0.1, effects: ['explode', 'shy'] }}>
25
+ <YourApp />
26
+ </PoltrgeistProvider>
27
+ )
28
+ }
29
+ ```
30
+
31
+ `options` accepts the same `HauntOptions` as `poltrgeist.haunt()`. Effects are cleaned up automatically when the provider unmounts.
32
+
33
+ ### `Haunted`
34
+
35
+ A wrapper component that applies specific effects to a single element.
36
+
37
+ ```tsx
38
+ import { Haunted } from 'poltrgeist-react'
39
+
40
+ // renders a <button> with explode + wobble effects
41
+ <Haunted as="button" effects={['explode', 'wobble']} onClick={handleClick}>
42
+ Click me
43
+ </Haunted>
44
+ ```
45
+
46
+ `as` defaults to `'div'`. All other props are forwarded to the underlying element.
47
+
48
+ ### `usePoltrgeist`
49
+
50
+ A hook that returns a `ref` — attach it to any element to apply effects.
51
+
52
+ ```tsx
53
+ import { usePoltrgeist } from 'poltrgeist-react'
54
+
55
+ function MyButton() {
56
+ const { ref } = usePoltrgeist(['shy', 'wobble'])
57
+ return <button ref={ref}>Hover me</button>
58
+ }
59
+ ```
60
+
61
+ ## License
62
+
63
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poltrgeist-react",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "React bindings for poltrgeist",
5
5
  "keywords": [
6
6
  "react",