react-rewards

Package containing a few microinteractions you can use to reward your users for little things and make them smile!

Github星跟蹤圖

react-rewards logo

npm version forthebadge

Demo available here!

Usage

This package was built using React-Pose, react-dom-confetti and Lottie-web.

Why should I use that? Read my blog post and you will know – https://www.thedevelobear.com/post/microinteractions/

Install from npm by typing npm install react-rewards or yarn add react-rewards while in your package.json directory.

This package lets you add microinteractions to your app, and rewards users with the rain of confettis, flying emoji or memphis design particles in seconds. In order to make it rain, you need to wrap your button of choice with the <Reward> component, fire the rewardMe() method from the refs and voilà. You can also "punish" the user by calling the punishMe() method and showing them that something went wrong.

import Reward from 'react-rewards';

// in render
<Reward
  ref={(ref) => { this.reward = ref }}
  type='emoji'
>
  <button onClick={this.fetchSomeData} />
</Reward>

// in fetchSomeData:
// to reward a user with confetti/emoji/memphis rain:
this.reward.rewardMe();
// to "punish" user :
this.reward.punishMe();

Props & config

Basic props:, name, type, description, required, default, -----------------, --------, --------------------------------------------------------, ------------, -------------, ref, func, function that creates a ref of the reward component, yes, type, string, 'confetti', 'emoji' or 'memphis', no, 'confetti', config, object, a configuration object described below, no, see below, Config object:, name, type, description, default (confetti / emoji), -----------------, --------, --------------------------------------------------------, ---------------------------, lifetime, number, time of life of each particle in ms, 200 / 200, angle, number, initial direction of particles in degrees, 90 / 90, decay, number, how much the velocity decreases with each frame, 0.91 / 0.91, spread, number, spread of particles in degrees, 45 / 100, startVelocity, number, initial velocity of particles, 35 / 20, elementCount, number, particles quantity, 40 / 15, elementSize, number, particle size in px, 8 / 20, zIndex, number, z-index of particles, 10 / 10, springAnimation, bool, whether the button should be animated, true, colors, array, An array of colors used when generating confettis, emoji, array, An array of emoji used when generating emoji particles

主要指標

概覽
名稱與所有者thedevelobear/react-rewards
主編程語言TypeScript
編程語言JavaScript (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2018-11-12 23:28:34
推送於2025-01-30 18:11:56
最后一次提交2025-01-29 23:39:42
發布數7
最新版本名稱v2.1.0 (發布於 )
第一版名稱v1.1.2 (發布於 )
用户参与
星數1.7k
關注者數4
派生數62
提交數106
已啟用問題?
問題數25
打開的問題數1
拉請求數53
打開的拉請求數2
關閉的拉請求數32
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?