An open API service indexing awesome lists of open source software.

https://github.com/brandly/react-tetris

:video_game: by popular demand
https://github.com/brandly/react-tetris

hacktoberfest

Last synced: over 1 year ago
JSON representation

:video_game: by popular demand

Awesome Lists containing this project

README

          

# react-tetris

![Build Status](https://github.com/brandly/react-tetris/workflows/.github/workflows/test.yml/badge.svg)

> Embed a game of Tetris in your React app

```shell
$ npm install --save react-tetris
```

[view demo](https://brandly.github.io/react-tetris/)

## usage

```js
const React = require('react');
const Tetris = require('react-tetris');

const App = () => (


Tetris



{({
HeldPiece,
Gameboard,
PieceQueue,
points,
linesCleared,
state,
controller
}) => (



Points: {points}


Lines Cleared: {linesCleared}





{state === 'LOST' && (

Game Over


New game

)}

)}


);
```

include some styles

```css
.game-block {
margin: 0;
padding: 0;
width: 1.5em;
height: 1.5em;
border: 1px solid #ddd;
}
.piece-i {
background-color: #ec858b;
}
.piece-j {
background-color: #f1b598;
}
.piece-l {
background-color: #f8efae;
}
.piece-o {
background-color: #b5a677;
}
.piece-s {
background-color: #816e56;
}
.piece-t {
background-color: #b77c72;
}
.piece-z {
background-color: #e3be58;
}
.piece-preview {
background-color: #eee;
}
```

## dev

```shell
$ npm run build
$ npm run watch
$ npm test
```