0.1.2 • Published 5 years ago

jw-color-picker v0.1.2

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

jw-color-picker

A react component for basic color selection.

NPM version build status node version npm download

Demo

Install

NPM

Methods

MethodParametersDescription
setColorr: integer. Default: 0g: integer. Default: 0b: integer. Default: 0a: integer. Default: 1set the color to be selected.
updateDialogPositionre-position the color dialog to be within the view as possible.

Props

PropDescription
paletteClassName(optional)the class name for the color palette. Default:
paletteStyle(optional)the inline style for the color palette. Default: {}
dialogWidth(optional)the width of the picker dialog. Default: 200
dialogHeight(optional)the height of the picker dialog. Default: 190
color(optional)the initial color to be selected. Default: random color
onChange(optional)the behavior on color change. Default: () => {}

Usage

import React, { Component } from "react";
import ReactDOM from "react-dom";
import ColorPicker from "jw-color-picker";

class Example extends Component {
  constructor(props) {
    super(props);

    this.state = {
      color: { r: 125, g: 125, b: 125, a: 1 }
    };
  }

  render() {
    const { color } = this.state;
    const { r, g, b, a } = color;

    return (
      <ColorPicker
        id="color-picker"
        color={color}
        onChange={value => this.setState({ color: value })}
      />
    );
  }
}

render(<Demo />, document.getElementById("root"));