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