JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
__tests__
example-plugin
flow-typed
lib
react-example.sketchplugin/Contents/Sketch
src
.babelrc
.eslintrc
.flowconfig
.gitignore
.npmignore
CHANGELOG.md
README.md
package.json
symlink-plugin.sh
webpack.config.js

README.md

react-sketch

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 the repo and symlink the examples:

git clone git@github.com:jongold/react-sketchapp.git
cd react-sketchapp
./symlink-plugin.sh

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 } from 'react-sketchapp';

const document = () => (
  <artboard>
    <group>
      <rect x={10} y={10} height={10} width={10} />
      <oval x={10} y={10} height={10} width={10} />
      <text value='yoooo' />
    </group>
  </artboard>
);

const onRun = (context) => {
  render(document, context, (element) => {
    console.log(element)
  });
};

Documentation

WIP!

<artboard />
type Artboard = {
  name?: string,
  children?: any,
  paddingTop?: number,
  paddingRight?: number,
  paddingBottom?: number,
  paddingLeft?: number,
  backgroundColor?: string,
};

<rect />
export type Rect = {
  name?: string,
  x: number,
  y: number,
  width: number,
  height: number,
  radius?: number,
  locked?: boolean,
  backgroundColor?: string,
}

<oval />
export type Oval = {
  name?: string,
  x: number,
  y: number,
  width: number,
  height: number,
  locked?: boolean,
  backgroundColor?: string,
}

<group />
export type Group = {
  name?: string,
  x?: number,
  y?: number,
  locked?: boolean,
  clickThrough?: boolean,
  children: any[],
}

<text>
export type Text = {
  name?: string,
  value: string,
  uppercase?: boolean,
  fontFamily: string,
  fontSize: number,
  color?: string,
  lineHeight?: number,
  opacity?: number,
  x?: number,
  y?: number,
  letterSpacing?: number,
  align?: 'left' | 'right' | 'center' | 'full',
  locked?: boolean,
}

Further Reading & inspiration

React Renderers

Sketch Plugins

Development