npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-coupon-wheel

v1.0.1

Published

A customizable React component for creating interactive coupon wheels

Downloads

13

Readme

CouponWheel React Component

A customizable, interactive coupon wheel component for React applications. Perfect for gamifying user engagement and promotional activities.

Disclaimer

The react-coupon-wheel is intended for promotional and entertainment purposes only. It is not designed or intended for use in gambling applications or on websites that are not compliant with Islamic (Halal) principles.

Features

  • Customizable wheel segments with labels and colors
  • Smooth spinning animation
  • Configurable indicator position
  • Option for predetermined winning segment
  • Responsive design
  • No external CSS dependencies - styles are bundled with the component

Installation

Install the package using npm:

npm install react-coupon-wheel

Or using yarn:

yarn add react-coupon-wheel

Usage

Here's a basic example of how to use the CouponWheel component:

import React from 'react';
import { CouponWheel } from 'react-coupon-wheel';

const App = () => {
  const wheelItems = [
    { label: '10% OFF', color: '#FF6B6B' },
    { label: '20% OFF', color: '#4ECDC4' },
    { label: '30% OFF', color: '#45B7D1' },
    { label: '40% OFF', color: '#F9DB6D' },
    { label: '50% OFF', color: '#FF8C42' },
    { label: 'FREE SHIP', color: '#98DDCA' },
  ];

  const handleSpinResult = (result) => {
    console.log('Spin result:', result);
  };

  return (
    <div>
      <h1>Try Your Luck!</h1>
      <CouponWheel
        wheelItems={wheelItems}
        onFinish={handleSpinResult}
      />
    </div>
  );
};

export default App;

Props

The CouponWheel component accepts the following props:

| Prop | Type | Default | Description | |------|------|---------|-------------| | wheelItems | Array of { label: string, color: string } | Required | Defines the segments of the wheel | | predeterminedWinner | string | undefined | Label of the predetermined winning segment | | spinDuration | number | 4000 | Duration of the spin animation in milliseconds | | spinDelay | number | 200 | Delay before the spin starts in milliseconds | | indicatorPosition | "12" | "3" | "6" | "9" | "12" | Position of the indicator on the wheel | | onFinish | function | undefined | Callback function called when spin finishes, receives the winning label as an argument | | isOpen | boolean | false | boolean to reset the wheel in case it is rendered inside a modal for example |

Styling

The component comes with default styles, but you can override them by targeting the following CSS classes:

  • .coupon-wheel-container: The main container of the wheel
  • .coupon-wheel-svg: The SVG element of the wheel
  • .wheel-segment: Each segment of the wheel
  • .wheel-border-light: The lights around the wheel border
  • .wheel-indicator: The indicator pointing to the winning segment

Development

To set up the project for development:

  1. Clone the repository
  2. Install dependencies with npm install
  3. Run the build process with npm run build
  4. To run tests (if available), use npm test

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

If you encounter any problems or have any questions, please open an issue in the GitHub repository.


Enjoy using CouponWheel in your React projects!