react-sketch-book

0.0.50 • Public • Published

License styled with prettier

React Sketch Book

Disclaimer ⚠️

Intro

This package is an helper to make all your components available into a Sketch document easily. It uses React Skecth.app under the hood and take care of all the configuration for you. You just have to write .sketch.js files for your components and run the build command.

The API is deeply inspired by the famous Storybook.

Requirement ⚠️

Getting Started 🏃

Install react-sketch-book package

npm i react-sketch-book --save -D

Add the command to your package.json

{
  "scripts": {
    "sketchbook": "react-sketch-book -p src"
  }
}

The -p or --path argument is the path of your project folder relative to your root directory where react-sketch-book is setup.

Write your sketch files

import React from 'react';
import { sketchOf } from 'react-sketch-book';
import Button from './Button'; // Component built with react-primitves or react-sketchapp
 
sketchOf('Button')
  .add('Button1', () => (<Button>Hello Button</Button>))
  .add('ButtonWithEmoji', () => (<Button>😀 😎 👍 💯</Button>));

Name your files with .sketch.js extension. eg: Button.sketch.js.

If you don't want to use .sketch.js extension for your files, you can provide a valid regexp using a flag into your script command -r or --regexp to change it.

{
  "scripts": {
    "sketchbook": "react-sketch-book -p src -r /\w+.sketch.js/gi"
  }
}

Build your Sketch Book

Open a new Sketch document if you haven't already and run the following command.

npm run sketchbook

Sample code

  • Download sketch (v47) and clone this repository
  • run npm install && npm run sketchbook

Thanks

Made with ♥️ for React

Package Sidebar

Install

npm i react-sketch-book

Weekly Downloads

2

Version

0.0.50

License

MIT

Last publish

Collaborators

  • rosatof