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-casino-roulette

v1.1.2

Published

The best React Casino Roulette

Downloads

42

Readme

React Casino Roulette

The first open source React casino roulette. This includes both table and wheel. No canvas used, only pure HTML, CSS, and JS for the best performance. No loading screens needed.

That's like selling. Fewer clicks mean more purchases. Faster loading speed leads to higher conversion rates.

Live example - react-casino-roulette.ivanadmaers.com
Another one - codesandbox.io/s/react-casino-roulette-example-ksw8u4

If you need the same functionality, plus 2 supported types (American and European roulette), and plain CSS and JS implementation, take a look at - https://github.com/IvanAdmaers/casino-roulette.

Please, pay your attention, some of the bet types names (STRAIGHT_UP, CORNER, etc) you receive when handeling user's bet may be incorrect. Everything else works great. It's fixed in https://github.com/IvanAdmaers/casino-roulette.

React Casino Roulette

Features

  • 🚀 No canvas, pure HTML, CSS, JS
  • 💪 The first open source casino roulette
  • 🔥 Table + Wheel
  • ⌛ No loading screens needed
  • ✅ Ease of use
  • 📝 MIT license
  • 📦 Lightweight
  • 🔧 Jest
  • 🎉 NextJS, GatsbyJS and RemixJS support

Installation

# Via npm:
npm i react-casino-roulette
# Via yarn:
yarn add react-casino-roulette

Usage

Table

import { useState } from 'react';
import { RouletteTable } from 'react-casino-roulette';

import 'react-casino-roulette/dist/index.css';

export const Table = () => {
  const [bets, setBets] = useState({});

  const handleBet = (betData) => {
    const { id } = betData;

    setBets((prevState) => ({
      ...prevState,
      [id]: {
        icon: 'https://cdn-icons-png.flaticon.com/512/10095/10095709.png',
      },
    }));
  };

  return (
    <div style={{ maxWidth: 800, margin: 'auto' }}>
      <RouletteTable bets={bets} onBet={handleBet} />
    </div>
  );
};

Wheel

import { useState } from 'react';
import { RouletteWheel } from 'react-casino-roulette';

import 'react-casino-roulette/dist/index.css';

export const Wheel = () => {
  const [start, setStart] = useState(false);
  const [winningBet, setWinningBet] = useState('-1');

  const doSpin = () => {
    setWinningBet('00');
    setStart(true);
  };

  return (
    <div>
      <div
        style={{ display: 'flex', justifyContent: 'center' }}
      >
        <RouletteWheel start={start} winningBet={winningBet} />
      </div>
      <div>
        <button type="button" disabled={start} onClick={doSpin}>
          Spin
        </button>
      </div>
    </div>
  );
};

Props

Where * means required

Table

| Prop | Type | Default value | Description | |--|--|--|--| | bets* | object | - | Object of bets for the table. See its BetType type here. | | onBet* | (params: IOnBetParams) => void | - | Triggers when user choose a bet on the table. See its IOnBetParams interface here | | isDebug | boolean | false | Sets debug mode |

Wheel

| Prop | Type | Default value | Description | |--|--|--|--| | start* | boolean | - | Sets when the wheel should start spinning | | winningBet* | string | - | Sets the wheel winning bet. Available values: -1, 0, 00 and 1 - 36 | | onSpinningEnd | () => void | () => undefined | Triggers when the wheel stops spinning | | withAnimation | boolean | true | Sets should the wheel plays rotating animation | | addRest | boolean | true | Adds an animation of the ball shifting after the end of the spinning |


FAQ

Where can I find an example of using this package?
💬 Use the links below:

How can I customize the table or wheel?
💬 At this moment this is possible by overriding default css styles.

Can I use this with SSR?
💬 Of course. And if you are using NextJS we would like to recommend you to import this package dynamically to decrease your project final bundle size.

What React versions does this package support?
💬 This project requires:

  • react >=17.0.0
  • react-dom >=17.0.0

Are ideas welcome?
💬 We value all ideas, improvements, suggestions and pull requests ❤️.

Local development

  1. Clone the project

  2. In the root directory run

npm ci i

npm start

The last command runs webpack to compile our package to a dist folder

  1. cd example/

  2. Run

npm ci i

npm start

The last command runs Webpack Dev Server so you can see the app in browser.

  1. Enjoy the power!

enjoying the power

License

MIT

IMAGE ALT TEXT HERE