UNPKG

1.32 kBTypeScriptView Raw
1import React from 'react';
2import extractViewBox from '../lib/extract/extractViewBox';
3import { NumberProp } from '../lib/extract/types';
4import Shape from './Shape';
5import { RNSVGMarker } from './NativeComponents';
6
7export default class Marker extends Shape<{
8 id?: string;
9 viewBox?: string;
10 preserveAspectRatio?: string;
11 refX?: NumberProp;
12 refY?: NumberProp;
13 markerWidth?: NumberProp;
14 markerHeight?: NumberProp;
15 markerUnits?: 'strokeWidth' | 'userSpaceOnUse';
16 orient?: 'auto' | 'auto-start-reverse' | NumberProp;
17}> {
18 static displayName = 'Marker';
19
20 static defaultProps = {
21 refX: 0,
22 refY: 0,
23 orient: '0',
24 markerWidth: 3,
25 markerHeight: 3,
26 markerUnits: 'strokeWidth',
27 };
28
29 render() {
30 const { props } = this;
31 const {
32 id,
33 viewBox,
34 preserveAspectRatio,
35 refX,
36 refY,
37 markerUnits,
38 orient,
39 markerWidth,
40 markerHeight,
41 children,
42 } = props;
43 const markerProps = {
44 name: id,
45 refX,
46 refY,
47 markerUnits,
48 orient: String(orient),
49 markerWidth,
50 markerHeight,
51 };
52
53 return (
54 <RNSVGMarker
55 ref={this.refMethod}
56 {...markerProps}
57 {...extractViewBox({ viewBox, preserveAspectRatio })}
58 >
59 {children}
60 </RNSVGMarker>
61 );
62 }
63}