# @scriptless/dice

> A representational, declarative dice component system for React apps.

Latest version **1.0.0-alpha.5** (published 2018-10-07) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @scriptless/dice
pnpm add @scriptless/dice
yarn add @scriptless/dice
bun add @scriptless/dice
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0-alpha.5 |
| Published | 2018-10-07 |
| First published | 2018-09-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 729.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Gus Nordhielm |
| Maintainers | gnordhielm |
| Keywords | react, dice, die, roll, animation, graphic, javascript |

## Links

- npm: https://www.npmjs.com/package/@scriptless/dice
- Repository: https://github.com/gnordhielm/scriptless.dice
- Homepage: https://github.com/gnordhielm/scriptless.dice#readme
- Issues: https://github.com/gnordhielm/scriptless.dice/issues
- npm.io page: https://npm.io/package/@scriptless/dice

## Dependencies (3)

- [svg.js](https://npm.io/package/svg.js.md) ^2.6.6
- [prop-types](https://npm.io/package/prop-types.md) ^15.6.2
- [@leiops/helpers](https://npm.io/package/@leiops/helpers.md) ^1.3.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0-alpha.5 (latest) — 2018-10-07
- 1.0.0-alpha.4 — 2018-09-27
- 1.0.0-alpha.3 — 2018-09-27
- 1.0.0-alpha.2 — 2018-09-27
- 1.0.0-alpha.1 — 2018-09-27
- 1.0.0-alpha.0 — 2018-09-25

## README

# @scriptless/dice

<img src="https://siteless.co/assets/image/5710239819104256" width="600" />

[![npm](https://img.shields.io/npm/dt/@scriptless/dice.svg?style=flat-square)](https://www.npmjs.com/package/@scriptless/dice)
[![npm](https://img.shields.io/npm/v/@scriptless/dice.svg?style=flat-square)](https://www.npmjs.com/package/@scriptless/dice)

A representational, declarative dice component system for React apps.

<img src="https://siteless.co/assets/image/5631986051842048" width="325" />

## Quick Start

This library provides two exports: `DiceInterface` and `Die`.

`Die` is a simple, stateless component which renders given values. Don't worry about that now. All you need to know is that it gets the `--rolling` class when it's rolling, and you can target the whole component with `.die` and the pips with `.__pip`.

`DiceInterface` takes care of rolling, animating, and rendering your dice. It's extremely configurable, but to get started, this is all you need:

```jsx

class DiceContainer extends React.Component {

  diceInterface = new DiceInterface({
    onUpdate: dice => { this.setState(() => ({ dice }))},
    diceCount: 2,
  })

  state = {
    dice: diceInterface.getInitialState()
  }

  render() {
    return (
      <div 
        className="dice-container" 
        onClick={this.diceInterface.roll}
      >
          {this.diceInterface.render()}
      </div>
    )
  }
}

```

## To Do

* Switching to percentage-based positioning in the die svg has slowed things down, it might make sense to provide a prop for setting height and width. Ideally the svg would be friendly to css resizing (which we can do with @leiops/icon, so I think it is).

---
_Source: https://npm.io/package/@scriptless/dice · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
