UNPKG

1.03 kBTypeScriptView Raw
1import React, { ReactElement } from 'react';
2import extractGradient from '../lib/extract/extractGradient';
3import { NumberProp, TransformProps } from '../lib/extract/types';
4import Shape from './Shape';
5import { RNSVGLinearGradient } from './NativeComponents';
6
7export default class LinearGradient extends Shape<{
8 id?: string;
9 x1?: NumberProp;
10 y1?: NumberProp;
11 x2?: NumberProp;
12 y2?: NumberProp;
13 children?: ReactElement[];
14 transform?: number[] | string | TransformProps;
15 gradientTransform?: number[] | string | TransformProps;
16 gradientUnits?: 'objectBoundingBox' | 'userSpaceOnUse';
17}> {
18 static displayName = 'LinearGradient';
19
20 static defaultProps = {
21 x1: '0%',
22 y1: '0%',
23 x2: '100%',
24 y2: '0%',
25 };
26
27 render() {
28 const { props } = this;
29 const { x1, y1, x2, y2 } = props;
30 const linearGradientProps = { x1, y1, x2, y2 };
31 return (
32 <RNSVGLinearGradient
33 ref={this.refMethod}
34 {...linearGradientProps}
35 {...extractGradient(props, this)}
36 />
37 );
38 }
39}