mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-06 06:19:58 +08:00
add types for Platform
This commit is contained in:
6
types/react-sketchapp/index.d.ts
vendored
6
types/react-sketchapp/index.d.ts
vendored
@@ -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
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user