GithubHelp home page GithubHelp logo

react-sketch-book's Introduction

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

react-sketch-book's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.