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

README.md

react-sketch

Build Status npm

Declarative bridge to Sketch.app.

WIP; not ready for public consumption yet!

Running example scripts

Make sure Sketch automatically reloads plugins:

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

Clone & build the repo, and symlink the examples:

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

Open Sketch; examples will be in Plugins -> react-example.

Using react-sketchapp

Check out:

webpack.config.js
example-plugin/
  *.js (raw sources)
react-example.sketchplugin
  Contents/
    Sketch/
      manifest.json
      *.js (compiled code)

You'll want to create a new repo, create a similar build process to ^^^, and implement your handler ~= this:

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

const Document = () => (
  <Artboard>
    <View>
      <View
        style={{
          height: 10,
          width: 10,
          backgroundColor: '#333',
        }}
      />
      <Text
        style={{
          fontSize: 24,
          fontFamily: 'FontFoo-PostscriptName',
          //etc
        }}
        children='yoooo'
      />
    </View>
  </Artboard>
);

const onRun = (context) => {
  render(<Document />, context);
};

Documentation

WIP, sorry. <View /> & <Text /> mirror their react-native / react-primitives counterparts - have fun with full flexbox layout.

Further Reading & inspiration

React Renderers

Sketch Plugins