1.0.3 • Published 3 years ago

react-graphic-key v1.0.3

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

react-graphic-key

Customizable ReactJS component of graphic key

NPM JavaScript Style Guide

Demo

Install

npm install --save react-graphic-key

Usage

import React from 'react'
import GraphicKey from 'react-graphic-key'

function App() {
  render() {
    return <GraphicKey onEnd={points => alert('Selected '+points.join(', '))} />
  }
}

Component props

GraphicKeycomponentprops
widthoptional (default: 3)Number of points in width for graphic key area
heightoptional (default: 3)Number of points in height for graphic key area
onEndoptional (function)Callback which will be called with 1 argument — array of numbers, selected points
stylingsoptional (object)Object of styles for graphic key area (see fields below)

Customization

In order to customize component, you have to pass stylings object as prop.

stylingsobjectfields
borderColorcss color stringColor of point border
borderWidthcss color stringWidth of point border
backgroundColorcss color stringBackground color of point
pointSizenumber of pixelsBackground color of point
pointMarginnumber of pixelsouter margin from interactive area to row border
animateOnSelecttrue or falseIf true, background will change from transparent to backgroundColor on selection
hideLinetrue or falseIf true, selection line between points will be hidden
lineColorcss color stringColor of selection line
lineWidthnumber of pixelsWidth of selection line

css color string may be hex (#121212), rgb/rgba (rgba(0, 0, 0, 0.25)) or hsl.

Examples

import React from 'react'
import GraphicKey from 'react-graphic-key'

function App() {
  render() {
    return <GraphicKey width={3} height={1} />
  }
}
import React from 'react'
import GraphicKey from 'react-graphic-key'

function App() {
  render() {
    return <GraphicKey width={4} height={4} stylings={{
        backgroundColor: 'green',
        borderColor: 'blue'
      }} />
  }
}

IDs

ID of each point is count of points in row multiplied by row index plus it's position in row:

1 2 3
4 5 6
7 8 9

OR

 1  2  3  4  5
 6  7  8  9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25

OR

1 2 3 4  5
6 7 8 9 10

License

MIT © VityaSchel

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago