1.0.2 • Published 4 years ago

@jswork/react-dice v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

react-dice

Dice for react.

version license size download

installation

npm install -S @jswork/react-dice

properties

NameTypeRequiredDefaultDescription
classNamestringfalse-The extended className for component.
valuenumberfalse1The changed value.
onChangefuncfalsenoopThe change handler.
disabledboolfalsefalseIf dice can be click.
durationnumberfalse500The dice rotate speed.
timeoutnumberfalse2000The timeout timing.

usage

  1. import css

    @import "~@jswork/react-dice/dist/style.css";
    
    // or use sass
    @import "~@jswork/react-dice/dist/style.scss";
    
    // customize your styles:
    $react-dice-options: ()
  2. import js

    import ReactDemokit from '@jswork/react-demokit';
    import React from 'react';
    import ReactDOM from 'react-dom';
    import ReactDice from '@jswork/react-dice';
    import './assets/style.scss';
    
    class App extends React.Component {
      state = {
        value: 3
      };
    
      handleChange = (e) => {
        this.setState({ value: e.target.value });
      };
    
      render() {
        return (
          <ReactDemokit
            className="p-3 app-container"
            url="https://github.com/afeiship/react-dice">
            <h1 className="title">骰子</h1>
            <h2 className="subtitle">😎点击开始玩吧~</h2>
            <div className="box">
              <ReactDice value={this.state.value} onChange={this.handleChange} />
            </div>
    
            <h1 className="text-center text-white">
              <span className="tag is-danger" style={{ fontSize: 80 }}>
                {this.state.value}
              </span>
            </h1>
          </ReactDemokit>
        );
      }
    }
    
    ReactDOM.render(<App />, document.getElementById('app'));

documentation

license

Code released under the MIT license.