dopaminejs 3.5.0 → 3.6.0
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.
- package/README.md +13 -2
- package/dist/{DataService-QQBNqJtN.js → DataService-B5noGvMr.js} +228 -254
- package/dist/DataService-DKCk0nOu.cjs +1 -0
- package/dist/SoundManager-C6VdZEFo.js +308 -0
- package/dist/SoundManager-DBGDYIkz.cjs +1 -0
- package/dist/celebrate.cjs +1 -0
- package/dist/celebrate.js +100 -0
- package/dist/core.cjs +1 -1
- package/dist/core.js +3 -1
- package/dist/dopamine.cjs +1 -1
- package/dist/dopamine.global.js +3 -3
- package/dist/dopamine.js +5 -3
- package/dist/host-B-Gn-Zg_.js +537 -0
- package/dist/host-D6suk7Ci.cjs +37 -0
- package/dist/storage-B6z-zaBe.cjs +1 -0
- package/dist/storage-C2s4Da9b.js +26 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.js +3 -2
- package/package.json +10 -3
- package/src/celebrate.js +208 -0
- package/src/dopamine/effects/ParticleSystem.js +5 -1
- package/src/dopamine/ui/RewardUI.js +10 -6
- package/types/celebrate.d.ts +31 -0
- package/types/index.d.ts +2 -0
- package/dist/DataService-Xk7egYXe.cjs +0 -1
- package/dist/host-1c7QSAKI.cjs +0 -37
- package/dist/host-_essSMef.js +0 -835
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# dopaminejs
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Gamification for any website. XP, levels, achievements and timezone-correct daily streaks, with confetti, particles and sound.
|
|
4
4
|
|
|
5
|
-
Zero runtime dependencies. Works with any framework.
|
|
5
|
+
Zero runtime dependencies. Works with any framework, or with no build step through the script tag build (3.4.0 and later, see the repository README).
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install dopaminejs
|
|
@@ -124,6 +124,17 @@ To put the card on the left, set `--dopamine-toast-right: auto` as well. With bo
|
|
|
124
124
|
|
|
125
125
|
Cards show one at a time. A second unlock waits until the first has left, so its announcement and confetti come later too.
|
|
126
126
|
|
|
127
|
+
## Celebrate a moment
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
import { celebrate } from 'dopaminejs/celebrate';
|
|
131
|
+
|
|
132
|
+
celebrate('complete', { title: 'Lesson 3 done', target: button });
|
|
133
|
+
celebrate('certificate', { parts: dopamine.parts }); // through a host
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Shows a toast, fires confetti and plays a sound, with or without `createDopamine()`. Presets: `complete`, `milestone`, `streak`, `certificate`. Options: `title`, `body`, `icon`, `target` (confetti starts at its centre), `sound` (a key, or `false`) and `parts`. With reduced motion on there is no confetti. A part the host does not have is skipped, with no standalone fallback. `destroyCelebrations()` removes what the standalone route made. Not in the script tag build.
|
|
137
|
+
|
|
127
138
|
## Cleanup
|
|
128
139
|
|
|
129
140
|
Everything that touches the DOM can be torn down:
|