1.0.1 • Published 10 months ago

react-coupon-wheel v1.0.1

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
10 months ago

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:

PropTypeDefaultDescription
wheelItemsArray of { label: string, color: string }RequiredDefines the segments of the wheel
predeterminedWinnerstringundefinedLabel of the predetermined winning segment
spinDurationnumber4000Duration of the spin animation in milliseconds
spinDelaynumber200Delay before the spin starts in milliseconds
indicatorPosition"12" | "3" | "6" | "9""12"Position of the indicator on the wheel
onFinishfunctionundefinedCallback function called when spin finishes, receives the winning label as an argument
isOpenbooleanfalseboolean 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!

1.0.1

10 months ago

1.0.0

10 months ago