add types for Platform

This commit is contained in:
Rico Kahler
2017-11-19 22:37:32 -05:00
parent e75aadc3c9
commit 6745ff3ed4
2 changed files with 30 additions and 19 deletions

View File

@@ -275,3 +275,9 @@ export function makeSymbol<P>(
* Injects the symbols into Sketch's symbol page. **Call this before rendering.**
*/
export function injectSymbols(context: SketchContext): void;
export const Platform: {
OS: 'sketch',
Version: 1,
select: (obj: any) => any
};

View File

@@ -1,24 +1,26 @@
import { Artboard, View, Text, StyleSheet, TextStyles, render, renderToJSON } from 'react-sketchapp';
import {
Artboard, View, Text, StyleSheet, TextStyles, render, renderToJSON, Platform
} from 'react-sketchapp';
// the styles object should be a mapped typed mapping the keys of the object literal to numbers
const styles = StyleSheet.create({
red: {
backgroundColor: '#FF00000'
},
flexRow: {
flexDirection: 'row'
}
red: {
backgroundColor: '#FF00000'
},
flexRow: {
flexDirection: 'row'
}
});
// style references are numbers
const styleReference = styles.red;
const Document = () => <Artboard name="some artboard name" style={{ backgroundColor: '#FF0000' }} >
<View name="some view name" style={{ backgroundColor: '#FF0000' }} >
<Text name="some text name">text must be a string</Text>
</View>
<View style={styles.red}>
</View>
<View name="some view name" style={{ backgroundColor: '#FF0000' }} >
<Text name="some text name">text must be a string</Text>
</View>
<View style={styles.red}>
</View>
</Artboard>;
render(<Document />);
@@ -31,11 +33,14 @@ Artboard.prototype.componentDidMount;
// TODO: currently this interface returns any but it looks like this method produces a side-affect
// and the return type isn't used anyway
TextStyles.create(context as any, {
normal: {
fontSize: 16,
},
heading: {
fontSize: 16 * 1.618,
fontWeight: 'bold',
}
normal: {
fontSize: 16,
},
heading: {
fontSize: 16 * 1.618,
fontWeight: 'bold',
}
});
const shouldBeSketch = Platform.OS;
const shouldBe1 = Platform.Version;