Giter VIP home page Giter VIP logo

react-slot-machine's Introduction

React Slot Machine

Example See live

npm install github:thomasrutzer/react-slot-machine#v1.0.3

Props

Property Description Type Default
ref Exposed ref React.ref null
symbols Symbols in use String[] ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
initialSymbols the result of the initial spin String[] ["0", "1", "2"]
symbolsPerSlot Amount of symbols per slot Number 20
symbolDefaultStyleClass Class which will be added to slot DOM element String "slotMachine__symbol"
symbolEvaluatedStyleClass Class which will be added after a symbol is evaluated String "slotMachine__symbol--evaluated"
onSpinningEnd Callback which will be invoked with result after spin Function () => {}

Usage

<SlotMachine
  symbols={ ["๐Ÿต", "๐Ÿท", "๐Ÿด"] }
  symbolDefaultStyleClass="๐Ÿ”ฆ"
  symbolEvaluatedStyleClass="๐Ÿ’ˆ"
  initialSymbols={ ["๐Ÿต", "๐Ÿท", "๐Ÿด"] }
  onSpinningEnd={ onSpinningEnd }
  ref={ slotMachineRef } />

Use ref to start spinning by calling exposed method spin

Local Development

Run a local version of rollup that will watch your src/ component and automatically recompile it into dist/ whenever you make changes.

npm link # the link commands are important for local development
npm install # disregard any warnings about missing peer dependencies
npm start # runs rollup with watch flag

Run example/ create-react-app that's linked to the local version of your react-slot-machine.

# (in another tab)
cd example
npm link react-slot-machine
npm install
npm start # runs create-react-app dev server

Build

# note this will build `commonjs` and `es`versions of your module to dist/
npm run build

react-slot-machine's People

Contributors

thomasrutzer avatar dependabot[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.