mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
Add Types for react-primitives (#26973)
* add types for react-primitives * Add new lines * remove custom linting rules
This commit is contained in:
committed by
Mohamed Hegazy
parent
ec281ea2f1
commit
566e039485
33
types/react-primitives/index.d.ts
vendored
Normal file
33
types/react-primitives/index.d.ts
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// Type definitions for react-primitives 0.6
|
||||
// Project: https://github.com/lelandrichardson/react-primitives
|
||||
// Definitions by: Ahmed Ghoneim <https://github.com/aghoneim92>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
import { ComponentType } from 'react';
|
||||
import {
|
||||
Animated,
|
||||
Dimensions,
|
||||
Easing,
|
||||
Image,
|
||||
PixelRatio,
|
||||
Platform,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableOpacityProps,
|
||||
View
|
||||
} from 'react-native';
|
||||
|
||||
export const Touchable: ComponentType<TouchableOpacityProps>;
|
||||
|
||||
export {
|
||||
Animated,
|
||||
Dimensions,
|
||||
Easing,
|
||||
Image,
|
||||
PixelRatio,
|
||||
Platform,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View
|
||||
};
|
||||
87
types/react-primitives/react-primitives-tests.tsx
Normal file
87
types/react-primitives/react-primitives-tests.tsx
Normal file
@@ -0,0 +1,87 @@
|
||||
import * as React from 'react';
|
||||
import {
|
||||
Animated,
|
||||
Dimensions,
|
||||
Easing,
|
||||
Image,
|
||||
PixelRatio,
|
||||
Platform,
|
||||
Text,
|
||||
Touchable,
|
||||
View,
|
||||
StyleSheet
|
||||
} from 'react-primitives';
|
||||
|
||||
const { Image: AnimatedImage } = Animated;
|
||||
|
||||
const { width, height } = Dimensions.get('window');
|
||||
const { width: screenWidth, height: screenHeight } = Dimensions.get('screen');
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
height: screenHeight
|
||||
},
|
||||
nav: {
|
||||
width: screenWidth,
|
||||
height: 20
|
||||
},
|
||||
image: {
|
||||
width,
|
||||
height: 100
|
||||
},
|
||||
text: {
|
||||
fontSize: 14 * PixelRatio.get()
|
||||
}
|
||||
});
|
||||
|
||||
interface State {
|
||||
opacity: Animated.Value;
|
||||
}
|
||||
|
||||
export default class Component extends React.Component<{}, State> {
|
||||
state: State = {
|
||||
opacity: new Animated.Value(0)
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
Animated.timing(this.state.opacity, {
|
||||
toValue: 1,
|
||||
duration: 10000,
|
||||
easing: Easing.cubic
|
||||
}).start();
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
state: { opacity }
|
||||
} = this;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={styles.nav}>
|
||||
<Text>My Awesome App!</Text>
|
||||
</View>
|
||||
<AnimatedImage
|
||||
style={[styles.image, { opacity }]}
|
||||
source={{ uri: 'source' }}
|
||||
/>
|
||||
<Image style={styles.image} source={{ uri: 'source' }} />
|
||||
<Text style={styles.text}>Hii</Text>
|
||||
{Platform.OS === 'ios' && (
|
||||
<View>
|
||||
<Text>IOS Specific Text!</Text>
|
||||
</View>
|
||||
)}
|
||||
<Touchable onPress={() => undefined}>
|
||||
<Text>Touch me!</Text>
|
||||
</Touchable>
|
||||
<View>
|
||||
<Text>Helloooooo</Text>
|
||||
<Touchable>
|
||||
<Text>Touch me too!</Text>
|
||||
</Touchable>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
20
types/react-primitives/tsconfig.json
Normal file
20
types/react-primitives/tsconfig.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-primitives-tests.tsx"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react",
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": []
|
||||
}
|
||||
}
|
||||
3
types/react-primitives/tslint.json
Normal file
3
types/react-primitives/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user