Permalink
Please sign in to comment.
Showing
with
405 additions
and 87 deletions.
- +1 −0 .eslintignore
- +1 −0 .gitignore
- +4 −2 CHANGELOG.md
- +13 −83 README.md
- +1 −0 SUMMARY.md
- +22 −0 book.json
- +14 −0 docs/README.md
- +16 −0 docs/api/Artboard.md
- +6 −0 docs/api/Platform.md
- +9 −0 docs/api/README.md
- +3 −0 docs/api/StyleSheet.md
- +11 −0 docs/api/Text.md
- +11 −0 docs/api/View.md
- +15 −0 docs/api/render.md
- +147 −0 docs/styling.md
- +27 −0 docs/troubleshooting.md
- +61 −0 docs/universal-rendering.md
- +7 −0 docs/usage.md
- +6 −0 package.json
- +7 −0 src/components/Artboard.js
- +6 −0 src/components/Text.js
- +6 −0 src/components/View.js
- +7 −0 src/render.js
- +3 −1 src/stylesheet/index.js
- +1 −1 src/utils/normalizeColor.js
| @@ -1,2 +1,4 @@ | ||
| -## 0.1.0 (Nov 28, 2016) | ||
| -Initial push | ||
| +# Change Log | ||
| + | ||
| +This project adheres to [Semantic Versioning](http://semver.org/). | ||
| +Every release, along with the migration instructions, is documented on the Github [Releases](https://github.com/jongold/react-sketchapp/releases) page. |
| @@ -0,0 +1 @@ | ||
| +docs/README.md |
| @@ -0,0 +1,22 @@ | ||
| +{ | ||
| + "gitbook": ">= 3.2.1", | ||
| + "title": "react-sketchapp", | ||
| + "plugins": [ | ||
| + "edit-link", | ||
| + "prism", | ||
| + "-highlight", | ||
| + "github", | ||
| + "-search", | ||
| + "codeblock-disable-glossary", | ||
| + "anchorjs" | ||
| + ], | ||
| + "pluginsConfig": { | ||
| + "edit-link": { | ||
| + "base": "https://github.com/jongold/react-sketchapp/tree/master", | ||
| + "label": "Edit This Page" | ||
| + }, | ||
| + "github": { | ||
| + "url": "https://github.com/jongold/react-sketchapp/" | ||
| + } | ||
| + } | ||
| +} |
| @@ -0,0 +1,14 @@ | ||
| +## Table of Contents | ||
| + | ||
| +* [Introduction](/README.md) | ||
| +* [Usage](/docs/usage.md) | ||
| +* [Styling](/docs/styling.md) | ||
| +* [Universal Rendering](/docs/universal-rendering.md) | ||
| +* [API Reference](/docs/api/README.md) | ||
| + * [render](/docs/api/render.md) | ||
| + * [Artboard](/docs/api/Artboard.md) | ||
| + * [Platform](/docs/api/Platform.md) | ||
| + * [StyleSheet](/docs/api/Stylesheet.md) | ||
| + * [Text](/docs/api/Text.md) | ||
| + * [View](/docs/api/View.md) | ||
| +* [Troubleshooting](/docs/troubleshooting.md) |
| @@ -0,0 +1,16 @@ | ||
| +# `Artboard` | ||
| + | ||
| +Artboard is a wrapper for Sketch artboards. | ||
| + | ||
| +#### Props | ||
| +- `name` _(String)_: The component name | ||
| +- `style` _(Style)_: See [styling](/docs/styling.md) | ||
| + | ||
| + | ||
| +#### Example | ||
| +```jsx | ||
| +const Document = () => | ||
| + <Artboard> | ||
| + <Text>Hello world!</Text> | ||
| + </Artboard> | ||
| +``` |
| @@ -0,0 +1,6 @@ | ||
| +# `Platform` | ||
| + | ||
| +#### Props | ||
| +- `OS` _(String)_ | ||
| +- `Version` _(Number)_ | ||
| +- `select` _(obj => obj) |
| @@ -0,0 +1,9 @@ | ||
| +# API Reference | ||
| + | ||
| +### Top-Level Exports | ||
| +- [render(element, context)](render.md) | ||
| +- [Artboard](Artboard.md) | ||
| +- [Platform](Platform.md) | ||
| +- [StyleSheet](Stylesheet.md) | ||
| +- [Text](Text.md) | ||
| +- [View](View.md) |
| @@ -0,0 +1,3 @@ | ||
| +# StyleSheet | ||
| + | ||
| +WIP |
| @@ -0,0 +1,11 @@ | ||
| +# Text | ||
| + | ||
| +WIP | ||
| + | ||
| +**Examples** | ||
| + | ||
| +```jsx | ||
| +<Text name='Foo' style={style}> | ||
| + Hello World! | ||
| +</Text> | ||
| +``` |
| @@ -0,0 +1,11 @@ | ||
| +# View | ||
| + | ||
| +WIP | ||
| + | ||
| +**Examples** | ||
| + | ||
| +```jsx | ||
| +<View name='Foo' style={style}> | ||
| + <Text /> | ||
| +</View> | ||
| +``` |
| @@ -0,0 +1,15 @@ | ||
| +# render | ||
| + | ||
| +Render a React element using a provided SketchContext. | ||
| + | ||
| +#### Parameters | ||
| +- `element` _(React$Element<any>)_ | ||
| +- `context` _(SketchContext)_ | ||
| + | ||
| +**Examples** | ||
| + | ||
| +```jsx | ||
| +const onRun = (context) => { | ||
| + render(<View />, context); | ||
| +} | ||
| +``` |
147
docs/styling.md
| @@ -0,0 +1,147 @@ | ||
| +# Styling | ||
| + | ||
| +Components use the same flexbox algorithm as `react-native`! | ||
| + | ||
| +#### Layout Styles | ||
| +```javascript | ||
| +export type ViewStyle = { | ||
| + // shadowColor: Color, | ||
| + // shadowOffset: { width: number, height: number }, | ||
| + // shadowOpacity: number, | ||
| + // shadowRadius: number, | ||
| + width: number, | ||
| + height: number, | ||
| + top: number, | ||
| + left: number, | ||
| + right: number, | ||
| + bottom: number, | ||
| + minWidth: number, | ||
| + maxWidth: number, | ||
| + minHeight: number, | ||
| + maxHeight: number, | ||
| + margin: number, | ||
| + marginVertical: number, | ||
| + marginHorizontal: number, | ||
| + marginTop: number, | ||
| + marginBottom: number, | ||
| + marginLeft: number, | ||
| + marginRight: number, | ||
| + padding: number, | ||
| + paddingVertical: number, | ||
| + paddingHorizontal: number, | ||
| + paddingTop: number, | ||
| + paddingBottom: number, | ||
| + paddingLeft: number, | ||
| + paddingRight: number, | ||
| + borderWidth: number, | ||
| + borderTopWidth: number, | ||
| + borderRightWidth: number, | ||
| + borderBottomWidth: number, | ||
| + borderLeftWidth: number, | ||
| + position: 'absolute' | 'relative', | ||
| + flexDirection: 'row' | 'row-reverse' | 'column' | 'column-reverse', | ||
| + flexWrap: 'wrap' | 'nowrap', | ||
| + justifyContent: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around', | ||
| + alignItems: 'flex-start' | 'flex-end' | 'center' | 'stretch', | ||
| + alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center' | 'stretch', | ||
| + // overflow: 'visible' | 'hidden' | 'scroll', | ||
| + flex: number, | ||
| + flexGrow: number, | ||
| + flexShrink: number, | ||
| + flexBasis: number, | ||
| + // aspectRatio: number, | ||
| + zIndex: number, | ||
| + // backfaceVisibility: 'visible' | 'hidden', | ||
| + backgroundColor: Color, | ||
| + borderColor: Color, | ||
| + borderTopColor: Color, | ||
| + borderRightColor: Color, | ||
| + borderBottomColor: Color, | ||
| + borderLeftColor: Color, | ||
| + borderRadius: number, | ||
| + borderTopLeftRadius: number, | ||
| + borderTopRightRadius: number, | ||
| + borderBottomLeftRadius: number, | ||
| + borderBottomRightRadius: number, | ||
| + borderStyle: 'solid' | 'dotted' | 'dashed', | ||
| + borderWidth: number, | ||
| + borderTopWidth: number, | ||
| + borderRightWidth: number, | ||
| + borderBottomWidth: number, | ||
| + borderLeftWidth: number, | ||
| + opacity: number, | ||
| +}; | ||
| +``` | ||
| + | ||
| +#### Type Styles | ||
| +```javascript | ||
| +export type TextStyle = { | ||
| + color: Color, | ||
| + fontFamily: string, | ||
| + fontSize: number, | ||
| + fontStyle: 'normal' | 'italic', | ||
| + fontWeight: string, | ||
| + // textShadowOffset: { width: number, height: number }, | ||
| + // textShadowRadius: number, | ||
| + // textShadowColor: Color, | ||
| + letterSpacing: number, | ||
| + lineHeight: number, | ||
| + textAlign: 'auto' | 'left' | 'right' | 'center' | 'justify', | ||
| + // writingDirection: 'auto' | 'ltr' | 'rtl', | ||
| +}; | ||
| +``` | ||
| + | ||
| +Styles can be passed to components as plain objects, or via [`StyleSheet`](/docs/api/StyleSheet.md). | ||
| + | ||
| +``` | ||
| +import { View, StyleSheet } from 'react-sketchapp'; | ||
| + | ||
| +// inline props | ||
| +<View | ||
| + style={{ | ||
| + backgroundColor: 'hotPink', | ||
| + width: 300, | ||
| + }} | ||
| +/> | ||
| + | ||
| +// plain JS object | ||
| +const style = { | ||
| + backgroundColor: 'hotPink', | ||
| + width: 300, | ||
| +} | ||
| + | ||
| +<View style={style} /> | ||
| + | ||
| +// StyleSheet | ||
| +const styles = StyleSheet.create({ | ||
| + foo: { | ||
| + backgroundColor: 'hotPink', | ||
| + width: 300, | ||
| + } | ||
| +}) | ||
| + | ||
| +<View style={styles.foo} /> | ||
| +<View style={[styles.foo, styles.bar]} /> | ||
| +``` | ||
| + | ||
| +You can use variables in your styles just like a standard React application: | ||
| +```javascript | ||
| +const colors = { | ||
| + Haus: '#F3F4F4', | ||
| + Night: '#333', | ||
| + Sur: '#96DBE4', | ||
| + Peach: '#EFADA0', | ||
| + Pear: '#93DAAB', | ||
| +}; | ||
| + | ||
| +<View> | ||
| + { Object.keys(colors).map(name => { | ||
| + <View | ||
| + style={{ | ||
| + flex: 1, | ||
| + backgroundColor: colors[name], | ||
| + }} | ||
| + /> | ||
| + }) } | ||
| +</View> | ||
| +``` |
Oops, something went wrong.
0 comments on commit
f17fdb4