@datacamp/react-native-linear-gradient
Advanced tools
Comparing version 2.1.2 to 2.4.1
@@ -1,11 +0,17 @@ | ||
// @flow | ||
/** | ||
* @providesModule LinearGradient | ||
* @flow | ||
*/ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { processColor, requireNativeComponent, PointPropType, StyleSheet, View, ViewPropTypes } from 'react-native'; | ||
import { processColor, PointPropType, StyleSheet, View, ViewPropTypes } from 'react-native'; | ||
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes'; | ||
const deprecatedPropType = require('react-native/Libraries/Utilities/deprecatedPropType.js'); | ||
import NativeLinearGradient from './nativeLinearGradient'; | ||
const convertPoint = (name, point) => { | ||
if (Array.isArray(point)) { | ||
console.warn( | ||
`LinearGradient '${name}' property shoule be an object with fields 'x' and 'y', ` + | ||
`LinearGradient '${name}' property should be an object with fields 'x' and 'y', ` + | ||
'Array type is deprecated.' | ||
@@ -21,11 +27,11 @@ ); | ||
type PropsType = { | ||
start?: Array<number> | {x: number, y: number}; | ||
end?: Array<number> | {x: number, y: number}; | ||
startPoint?: Array<number> | {x: number, y: number}; | ||
endPoint?: Array<number> | {x: number, y: number}; | ||
colors: Array<string>; | ||
locations?: Array<number>; | ||
} & typeof(View); | ||
} & ViewProps; | ||
export default class LinearGradient extends Component { | ||
static propTypes = { | ||
start: PropTypes.oneOfType([ | ||
startPoint: PropTypes.oneOfType([ | ||
PointPropType, | ||
@@ -37,3 +43,3 @@ deprecatedPropType( | ||
]), | ||
end: PropTypes.oneOfType([ | ||
endPoint: PropTypes.oneOfType([ | ||
PointPropType, | ||
@@ -60,5 +66,5 @@ deprecatedPropType( | ||
colors, | ||
end, | ||
endPoint, | ||
locations, | ||
start, | ||
startPoint, | ||
style, | ||
@@ -95,4 +101,4 @@ ...otherProps | ||
colors={colors.map(processColor)} | ||
start={convertPoint('start', start)} | ||
end={convertPoint('end', end)} | ||
startPoint={convertPoint('startPoint', startPoint)} | ||
endPoint={convertPoint('endPoint', endPoint)} | ||
locations={locations ? locations.slice(0, colors.length) : null} | ||
@@ -106,3 +112,1 @@ borderRadii={borderRadiiPerCorner} | ||
} | ||
const NativeLinearGradient = requireNativeComponent('BVLinearGradient', null); |
@@ -7,9 +7,12 @@ /** | ||
import PropTypes from 'prop-types'; | ||
import { processColor, requireNativeComponent, PointPropType, View, ViewPropTypes } from 'react-native'; | ||
import { processColor, PointPropType, View, ViewPropTypes } from 'react-native'; | ||
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes'; | ||
const deprecatedPropType = require('react-native/Libraries/Utilities/deprecatedPropType.js'); | ||
import NativeLinearGradient from './nativeLinearGradient'; | ||
const convertPoint = (name, point) => { | ||
if (Array.isArray(point)) { | ||
console.warn( | ||
`LinearGradient '${name}' property shoule be an object with fields 'x' and 'y', ` + | ||
`LinearGradient '${name}' property should be an object with fields 'x' and 'y', ` + | ||
'Array type is deprecated.' | ||
@@ -27,11 +30,11 @@ ); | ||
type PropsType = { | ||
start?: Array<number> | {x: number, y: number}; | ||
end?: Array<number> | {x: number, y: number}; | ||
startPoint?: Array<number> | {x: number, y: number}; | ||
endPoint?: Array<number> | {x: number, y: number}; | ||
colors: Array<string>; | ||
locations?: Array<number>; | ||
} & typeof(View); | ||
} & ViewProps; | ||
export default class LinearGradient extends Component { | ||
static propTypes = { | ||
start: PropTypes.oneOfType([ | ||
startPoint: PropTypes.oneOfType([ | ||
PointPropType, | ||
@@ -43,3 +46,3 @@ deprecatedPropType( | ||
]), | ||
end: PropTypes.oneOfType([ | ||
endPoint: PropTypes.oneOfType([ | ||
PointPropType, | ||
@@ -64,4 +67,4 @@ deprecatedPropType( | ||
const { | ||
start, | ||
end, | ||
startPoint, | ||
endPoint, | ||
colors, | ||
@@ -79,4 +82,4 @@ locations, | ||
{...otherProps} | ||
start={convertPoint('start', start)} | ||
end={convertPoint('end', end)} | ||
startPoint={convertPoint('startPoint', startPoint)} | ||
endPoint={convertPoint('endPoint', endPoint)} | ||
colors={colors.map(processColor)} | ||
@@ -88,3 +91,1 @@ locations={locations ? locations.slice(0, colors.length) : null} | ||
} | ||
const NativeLinearGradient = requireNativeComponent('BVLinearGradient', null); |
{ | ||
"name": "@datacamp/react-native-linear-gradient", | ||
"version": "2.1.2", | ||
"version": "2.4.1", | ||
"description": "A <LinearGradient> element for react-native", | ||
@@ -5,0 +5,0 @@ "main": "index", |
@@ -135,7 +135,7 @@ # react-native-linear-gradient | ||
#### start | ||
#### startPoint | ||
An optional object of the following type: `{ x: number, y: number }`. Coordinates declare the position that the gradient starts at, as a fraction of the overall size of the gradient, starting from the top left corner. Example: `{ x: 0.1, y: 0.1 }` means that the gradient will start 10% from the top and 10% from the left. | ||
#### end | ||
Same as start, but for the end of the gradient. | ||
#### endPoint | ||
Same as `startPoint`, but for the end of the gradient. | ||
@@ -147,3 +147,3 @@ #### locations | ||
<LinearGradient | ||
start={{x: 0.0, y: 0.25}} end={{x: 0.5, y: 1.0}} | ||
startPoint={{x: 0.0, y: 0.25}} endPoint={{x: 0.5, y: 1.0}} | ||
locations={[0,0.5,0.6]} | ||
@@ -171,4 +171,7 @@ colors={['#4c669f', '#3b5998', '#192f6a']} | ||
### Other platforms | ||
- Web: [react-native-web-community/react-native-web-linear-gradient](https://github.com/react-native-web-community/react-native-web-linear-gradient) | ||
### License | ||
License is MIT |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
175
956548
23
194
1