0.5.1 • Published 5 years ago

react-sketch v0.5.1

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

react-sketch

GitHub release NPM release NPM downloads Build status

A Sketch tool for React based applications, backed-up by FabricJS

idea-image Please note that this module is still in development! Feel free to send me enhancements and ideas :)

Installation

npm install react-sketch --save

or with yarn

yarn add react-sketch

Source installation

In order to build from source, read the relevant instructions first.

Tested with node versions 6,7,8.

Usage

Import the relevant SketchField component and use it, you can find more on the examples folder of the project

import {SketchField, Tools} from 'react-sketch';

class SketchFieldDemo extends React.Component {
     render() {
        return (
            <SketchField width='1024px' 
                         height='768px' 
                         tool={Tools.Pencil} 
                         lineColor='black'
                         lineWidth={3}/>
        )
     }
}

Configuration Options

OptionTypeDefaultDescription
toolEnumeration (string)pencilThe tool to use, can be select, pencil, circle, rectangle, pan
lineColorStringblackThe color of the line
lineWidthNumber1The width of the line
fillColorStringtransparentThe fill color (hex format) of the shape when applicable (e.g. circle)
backgroundColorStringtransparentThe the background color of the sketch in hex or rgba
undoStepsNumber15number of undo/redo steps to maintain
imageFormatStringpngimage format when calling toDataURL, can be png or jpeg
widthNumberNo Value(null)Set/control the canvas width, if left empty the sketch will scale to parent element
heightNumber512Set/control the canvas height, if left empty the sketch will take a reasonable default height
valueJSONProperty to utilize and handle the sketch data as controlled component
defaultValueJSONDefault initial data, to load. If value is set then value will be loaded instead
widthCorrectionNumber2Specify some width correction which will be applied on resize of canvas, this will help to correct some possible border on the canvas style
heightCorrectionNumber0Specify some height correction which will be applied on resize of canvas, this will help to correct some possible border on the canvas style

Available tools

ToolDescription
PencilFree drawing pencil
LineGives you the ability to draw lines
RectangleCreate rectangles
CircleCreate circles
RectangleCreate Rectangles
SelectDisables drawing and gives you the ability to modify existing elements in the canvas
PanDisables drawing and gives you the ability to move the complete canvas at will, useful to adjust the canvas when zooming in or out (thank you wmaillard)

Examples

The project includes a webpack server for running the examples, just run:

git clone https://github.com/tbolis/react-sketch.git
yarn install
npm start

and navigate to http://localhost:23000

You can as well check the live showcase here: http://tbolis.github.io/showcase/react-sketch/

Issues

See https://github.com/tbolis/react-sketch/issues

Changelog

See https://github.com/tbolis/react-sketch/blob/master/CHANGELOG.md

License

MIT, do remember to add a reference if you find it useful :)

0.5.1

5 years ago

0.5.0

5 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.13

7 years ago

0.2.12

8 years ago

0.2.11

8 years ago

0.2.10

8 years ago

0.2.9

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago