UNPKG

1.16 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 { RNSVGRadialGradient } from './NativeComponents';
6
7export default class RadialGradient extends Shape<{
8 fx?: NumberProp;
9 fy?: NumberProp;
10 rx?: NumberProp;
11 ry?: NumberProp;
12 r?: NumberProp;
13 cx?: NumberProp;
14 cy?: NumberProp;
15 id?: string;
16 children?: ReactElement[];
17 transform?: number[] | string | TransformProps;
18 gradientTransform?: number[] | string | TransformProps;
19 gradientUnits?: 'objectBoundingBox' | 'userSpaceOnUse';
20}> {
21 static displayName = 'RadialGradient';
22
23 static defaultProps = {
24 cx: '50%',
25 cy: '50%',
26 r: '50%',
27 };
28
29 render() {
30 const { props } = this;
31 const { rx, ry, r, cx, cy, fx = cx, fy = cy } = props;
32 const radialGradientProps = {
33 fx,
34 fy,
35 rx: rx || r,
36 ry: ry || r,
37 cx,
38 cy,
39 };
40 return (
41 <RNSVGRadialGradient
42 ref={this.refMethod}
43 {...radialGradientProps}
44 {...extractGradient(props, this)}
45 />
46 );
47 }
48}