Skip to content

Instantly share code, notes, and snippets.

@patrickhpan
Created April 27, 2017 22:10
Show Gist options
  • Save patrickhpan/4852890475dfb0f964945d7ca1d7ea54 to your computer and use it in GitHub Desktop.
Save patrickhpan/4852890475dfb0f964945d7ca1d7ea54 to your computer and use it in GitHub Desktop.
react-sketchapp: one per page
import React from 'react';
import { Artboard, View, Text, render } from 'react-sketchapp';
let content = [
<Artboard>Hello World</Artboard>,
<Artboard>Foo Bar</Artboard>
]
export default context => {
let document = context.document;
while(document.pages().length > 1) {
document.removePage(document.currentPage())
}
let pages = [context.document.currentPage()];
while(pages.length < content.length) {
pages.push(document.addBlankPage());
}
content.forEach((item, i) => {
render(item, pages[i])
let name = (item.type.name || `Page ${i}`)
pages[i].name = name
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment