JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
__tests__
docs
example-plugin
flow-typed
src
.babelrc
.eslintignore
.eslintrc
.flowconfig
.gitignore
.jestrc
.travis.yml
CHANGELOG.md
CODE_OF_CONDUCT.md
README.md
SUMMARY.md
book.json
package.json
symlink-plugin.sh
webpack.config.js

README.md

This project is currently in alpha and APIs are subject to change. If you found the repo on npm β€” the source (& docs, oops) is private for now; it will be announced on my mailing list and Twitter very soon :)

react-sketchapp

A React renderer for Sketch.app βš›οΈ πŸ’Ž

npm CircleCI Sketch.app

Features

  • Declarative. All the lessons we've learnt from the React model of programming. A comfortable layer over Sketch’s API.
  • Familiar. Flexbox layouts. react-native components. You already know how to use react-sketchapp.
  • Data-based. Pipe in real data from JSON files, APIs, and databases.
  • Universal. Start from scratch, or use your existing component libraries

Documentation

Usage

react-sketchapp projects are implemented as Sketch plugins. First, make sure you've disabled Sketch's caching mechanism.

defaults write ~/Library/Preferences/com.bohemiancoding.sketch3.plist AlwaysReloadScript -bool YES

There are several ways to build Sketch plugins:

The simple way

The simplest way to build Sketch plugins with modern JavaScript is skpm πŸ’ŽπŸ“¦.

Install skpm, if you don't have it already, and create a new project.

npm install -g skpm
mkdir my-rad-sketch-plugin
cd my-rad-sketch-plugin
skpm init
skpm link .

Install some dependencies and set up JSX compilation

npm install --save react-sketchapp react react-test-renderer
npm install --save-dev babel-preset-react
echo '{"presets": ["react"]}' > .babelrc

Then, to build your plugin

skpm build --watch

And write your plugin in src/my-command.js

import React from 'react';
import { render, Text, View } from 'react-sketchapp';

const Document = props =>
  <View>
    <Text>Hello world!</Text>
  </View>;

export default function (context) {
  render(<Document />, context);
}

Run your plugin in Sketch via Plugins β†’ [your plugin name] β†’ my-command.

Refer to the skpm docs for more information.

The manual way

Feel free to use whatever build process you're comfortable with β€” just disable CocoaScript and you can use react-native-packager, rollup, webpack etc.

react-sketchapp-starter is a minimal boilerplace to start developing with Webpack.

Examples

react-sketchapp includes a folder of examples showing how you might use it to work with a JavaScript design system.

Clone & build the repo, and symlink the examples:

git clone git@github.com:jongold/react-sketchapp.git && cd react-sketchapp
npm install && npm run build:plugin
./symlink-plugin.sh

Open Sketch; examples will be in Plugins β†’ react-example.