Created
April 27, 2017 22:10
-
-
Save patrickhpan/4852890475dfb0f964945d7ca1d7ea54 to your computer and use it in GitHub Desktop.
react-sketchapp: one per page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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