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-nonogram-component

v1.1.7

Published

## Introduction

Downloads

20

Readme

React Nonogram Component

Introduction

This is a React component to display a Nonogram grid from the solution. Hints are automatically computed, and updated depending on the player moves.

Nonogram

Demo: https://qrcode-nonogram.netlify.app/

Npm package: https://www.npmjs.com/package/react-nonogram-component

Usage

Install

npm install react-nonogram-component

Prerequisites

You need React > 17 in your dependencies.

Example

A simple nonogram grid of 3 rows / 4 columns: https://stackblitz.com/edit/react-ts-zftptv?file=index.tsx

import { NonogramGrid } from "react-nonogram-component"
const solution = [
  true, true, false, true, 
  true, false, true, true,
  false, false, true, false,
];

return <NonogramGrid rows={3} cols={4} solution={solution} /></div>;

A demo project is under the demo/ directory.

Style

CSS can be overriden via CSS variables.

Here are the default values:

--game-grid-color: #444;
--hint-font-family: monospace;
--hint-color: #000;
--hint-crossout-color: #bbb;
--hint-overflow-background: rgba(255, 0, 0, 0.1);
--game-board-background-color: #bbb;
--mouse-highlight-color: #f5e9e9;
--square-filled-background-color: #353235fa; # With transparency to display the mouse highlight
--square-empty-background-color: #fffffffa;
--square-marked-background-color: #fffffffa;
--square-marked-symbol-color: #bbb;
--square-marked-symbol: "\\2738";

Component parameters

rows: Number of rows of the grid

cols: Number of columns of the grid

solution: the solution for the grid (1D array)

type Solution = (boolean | SquareValue.EMPTY | SquareValue.FILLED)[] // 1D array with all square values

init: initial grid displayed to the player (1D array)

type Init = (SquareValue.EMPTY | SquareValue.FILLED | SquareValue.MARKED)[] // 1D array with all square values

onRefresh: Event function: called each time the nonogram is refreshed. It allows the developer to interact with the grid.

function onRefresh(action: NonogramActions): void

export interface NonogramActions {
  canUndo: boolean // true if user can undo its last move, else false
  canRedo: boolean // true if user can redo its last move, else false
  undo: () => void // undo the last move
  redo: () => void // redo the last move
  restart: () => void // restart the game
  setGridHidden: (hidden: boolean) => void // hide the borders of the grid
  nextState: (grid: SquareValue[]) => void // set  the next grid in history (1D array with all square values)
  getProgress: () => number // get the progress of the game in % (value from 0 to 100)
  getCurrentBoard: () => SquareValue[] // get the square values of the displayed board
}

Build the lib

yarn build # one shot build
yarn watch # build when a file is modified (dev mode)

Run the sample

cd sample/
yarn start