mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
[react-native-linear-gradient] Add Typings (#20377)
* Add LinearGradient typings * Fix typo in props type * Enable strictFunctionTypes and fix lint errors
This commit is contained in:
committed by
Wesley Wigham
parent
4f8a3d571b
commit
4bfdd6f053
+47
@@ -0,0 +1,47 @@
|
||||
// Type definitions for react-native-linear-gradient 2.3
|
||||
// Project: https://github.com/brentvatne/react-native-linear-gradient#readme
|
||||
// Definitions by: Jacob Froman <https://github.com/j-fro>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as React from 'react';
|
||||
import { ViewProperties } from 'react-native';
|
||||
|
||||
interface LinearGradientProps extends ViewProperties {
|
||||
children?: React.ReactNode;
|
||||
|
||||
/**
|
||||
* Colors that will be used for the gradient
|
||||
*/
|
||||
colors?: ReadonlyArray<string>;
|
||||
|
||||
/**
|
||||
* Coordinates of the position that the gradient starts at, as a fraction
|
||||
* of the overall size of the gradient, starting from the top left corner.
|
||||
* { x: 0.1, y: 0.1 } means that the gradient will start 10% from the top
|
||||
* and 10% from the left.
|
||||
*/
|
||||
start?: { x: number; y: number };
|
||||
|
||||
/**
|
||||
* Coordinates of the position that the gradient ends at, as a fraction
|
||||
* of the overall size of the gradient, starting from the top left corner.
|
||||
* { x: 0.9, y: 0.9 } means that the gradient will end 90% from the top
|
||||
* and 90% from the left.
|
||||
*/
|
||||
end?: { x: number; y: number };
|
||||
|
||||
/**
|
||||
* An optional array of numbers defining the location of each gradient
|
||||
* color stop, mapping to the color with the same index in colors prop.
|
||||
* [0.1, 0.75, 1] means that first color will take 0% - 10%, second color
|
||||
* will take 10% - 75% and finally third color will occupy 75% - 100%.
|
||||
*/
|
||||
locations?: ReadonlyArray<number>;
|
||||
}
|
||||
|
||||
declare class LinearGradient extends React.Component<LinearGradientProps> {
|
||||
constructor(props: LinearGradientProps);
|
||||
}
|
||||
|
||||
export default LinearGradient;
|
||||
@@ -0,0 +1,35 @@
|
||||
import * as React from 'react';
|
||||
import LinearGradient from 'react-native-linear-gradient';
|
||||
import { Text, StyleSheet } from 'react-native';
|
||||
|
||||
export default class MyLinearGradient extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<LinearGradient
|
||||
colors={['#4c669f', '#3b5998', '#192f6a']}
|
||||
start={{ x: 0.0, y: 0.25 }}
|
||||
end={{ x: 0.5, y: 1.0 }}
|
||||
locations={[0, 0.5, 0.6]}
|
||||
style={styles.linearGradient}
|
||||
>
|
||||
<Text style={styles.buttonText}>Sign in with Facebook</Text>
|
||||
</LinearGradient>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
linearGradient: {
|
||||
flex: 1,
|
||||
paddingLeft: 15,
|
||||
paddingRight: 15,
|
||||
borderRadius: 5
|
||||
},
|
||||
buttonText: {
|
||||
fontSize: 18,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
color: '#ffffff',
|
||||
backgroundColor: 'transparent'
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react-native"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-native-linear-gradient-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user