on 231316e help sign in
bridge/src/bridge/components/ReactSVGComponents.js
63 lines 1.7 kB history raw
1import React from 'react'
2import { get, map } from 'lodash'
4const ReactSVGComponents = {
5 svg: (p, key) => {
6 return (
7 <svg {...p.attr} version={'1.1'} xmlns={'http://www.w3.org/2000/svg'} key={key}>
8 { map(get(p, 'children', []), (child, idx) => ReactSVGComponents[child.tag](child, idx)) }
9 </svg>
10 )
11 },
12 circle: (p, key) => {
13 return (
14 <circle {...p.attr} key={key}>
15 { map(get(p, 'children', []), (child, idx) => ReactSVGComponents[child.tag](child, idx)) }
16 </circle>
17 )
18 },
19 rect: (p, key) => {
20 return (
21 <rect {...p.attr} key={key}>
22 { map(get(p, 'children', []), (child, idx) => ReactSVGComponents[child.tag](child, idx)) }
23 </rect>
24 )
25 },
26 path: (p, key) => {
27 return (
28 <path {...p.attr} key={key}>
29 { map(get(p, 'children', []), (child, idx) => ReactSVGComponents[child.tag](child, idx)) }
30 </path>
31 )
32 },
33 g: (p, key) => {
34 return (
35 <g {...p.attr} key={key}>
36 { map(get(p, 'children', []), (child, idx) => ReactSVGComponents[child.tag](child, idx)) }
37 </g>
38 )
39 },
40 polygon: (p, key) => {
41 return (
42 <polygon {...p.attr} key={key}>
43 { map(get(p, 'children', []), (child, idx) => ReactSVGComponents[child.tag](child, idx)) }
44 </polygon>
45 )
46 },
47 line: (p, key) => {
48 return (
49 <line {...p.attr} key={key}>
50 { map(get(p, 'children', []), (child, idx) => ReactSVGComponents[child.tag](child, idx)) }
51 </line>
52 )
53 },
54 polyline: (p, key) => {
55 return (
56 <polyline {...p.attr} key={key}>
57 { map(get(p, 'children', []), (child, idx) => ReactSVGComponents[child.tag](child, idx)) }
58 </polyline>
59 )
60 }
63export default ReactSVGComponents