1.0.1 â€Ē Published 7 months ago

ngx-rewards v1.0.1

Weekly downloads
-
License
-
Repository
github
Last release
7 months ago

NgxRewards 🎉

Here is a simple demo

Table of Contents

About

ngx-rewards lets you add micro-interactions to your app, and reward users with the rain of confetti, emoji or balloons in seconds. Firing confetti all over the page may seem like a questionable idea, but keep in mind that rewarding users for their actions is not.

Installation

ng add ngx-rewards

or

npm install ngx-rewards

// app.module.ts

import { NgxRewardsModule } from 'ngx-rewards';

@NgModule({
  declarations: [...],
  imports: [..., NgxRewardsModule],
  providers: [],
  bootstrap: [...],
})
export class AppModule {}
// app.component.ts

import { EmojiConfig } from 'ngx-rewards';

@Component({...})
export class AppComponent {
  defaultEmoji = ['ðŸĪ“', '😊', 'ðŸĨģ', '😃', 'ðŸĪŠ', 'ðŸ”Ĩ', '🎉'];

  emojiConfig: EmojiConfig = {
    elementCount: 50,
    elementSize: 20,
  };
}
// app.component.html

<button ngxRewardsEmoji
        [emojiConfig]="emojiConfig"
        class="button">
  Emoji
</button>

<button ngxRewardsConfetti
        class="button">
  Confetti
</button>

<button ngxRewardsBalloon
        class="button">
  Balloons
</button>

<button ngxRewardsEmoji
        ngxRewardsBalloon
        ngxRewardsConfetti
        class="button">
  All 3
</button>

Props & config

Confetti config object:

nametypedescriptiondefault
lifetimenumbertime of life200
anglenumberinitial direction of particles in degrees90
decaynumberhow much the velocity decreases with each frame0.94
spreadnumberspread of particles in degrees45
startVelocitynumberinitial velocity of particles35
elementCountnumberparticles quantity50
elementSizenumberparticle size in px8
zIndexnumberz-index of particles0
positionstringone of CSSProperties'position' - e.g. "absolute""fixed"
colorsstring[]An array of colors used when generating confetti'#A45BF1', '#25C6F6', '#72F753', '#F76C88', '#F5F770'
onAnimationComplete() => voidA function that runs when animation completesundefined

Balloons config object:

nametypedescriptiondefault
lifetimenumbertime of life600
anglenumberinitial direction of balloons in degrees90
decaynumberhow much the velocity decreases with each frame0.999
spreadnumberspread of balloons in degrees50
startVelocitynumberinitial velocity of the balloons3
elementCountnumberballoons quantity10
elementSizenumberballoons size in px20
zIndexnumberz-index of balloons0
positionstringone of CSSProperties'position' - e.g. "absolute""fixed"
colorsstring[]An array of colors used when generating balloons'#A45BF1', '#25C6F6', '#72F753', '#F76C88', '#F5F770'
onAnimationComplete() => voidA function that runs when animation completesundefined

Emoji config object:

nametypedescriptiondefault
lifetimenumbertime of life200
anglenumberinitial direction of emoji in degrees90
decaynumberhow much the velocity decreases with each frame0.94
spreadnumberspread of emoji in degrees45
startVelocitynumberinitial velocity of emoji35
elementCountnumberemoji quantity20
elementSizenumberemoji size in px25
zIndexnumberz-index of emoji0
positionstringone of CSSProperties'position' - e.g. "absolute""fixed"
emojistring[]An array of emoji to shoot'ðŸĪ“', '😊', 'ðŸĨģ', '😃', 'ðŸĪŠ', 'ðŸ”Ĩ', '🎉'
onAnimationComplete() => voidA function that runs when animation completesundefined

Contributing

If you would like to contribute to this project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and test them thoroughly.
  4. Create a pull request with a clear description of you changes.

License

This News App project is licensed under the MIT License. Feel free to use and modify it as per your requirements.

1.0.1

7 months ago

1.0.0

7 months ago