项目作者: WaiChungWong

项目描述 :
A react component for basic color selection.
高级语言: JavaScript
项目地址: git://github.com/WaiChungWong/jw-color-picker.git
创建时间: 2018-08-08T14:37:28Z
项目社区:https://github.com/WaiChungWong/jw-color-picker

开源协议:MIT License

下载


jw-color-picker

A react component for basic color selection.

NPM version
build status
node version
npm download

Demo

Install

NPM

Methods

Method Parameters Description
setColor r: integer. Default: 0
g: integer. Default: 0
b: integer. Default: 0
a: integer. Default: 1
set the color to be selected.
updateDialogPosition re-position the color dialog to be within the view as possible.

Props

Prop Description
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

  1. import React, { Component } from "react";
  2. import ReactDOM from "react-dom";
  3. import ColorPicker from "jw-color-picker";
  4. class Example extends Component {
  5. constructor(props) {
  6. super(props);
  7. this.state = {
  8. color: { r: 125, g: 125, b: 125, a: 1 }
  9. };
  10. }
  11. render() {
  12. const { color } = this.state;
  13. const { r, g, b, a } = color;
  14. return (
  15. <ColorPicker
  16. id="color-picker"
  17. color={color}
  18. onChange={value => this.setState({ color: value })}
  19. />
  20. );
  21. }
  22. }
  23. render(<Demo ></Demo>, document.getElementById("root"));