@@ -12,33 +12,109 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1212'use strict' ;
1313
1414import React from 'react' ;
15- import SLDS_ICONS_UTIL from './slds-icons-util' ;
15+ import SLDS_ICONS_UTILITY from './slds-icons-utility' ;
16+ import SLDS_ICONS_ACTION from './slds-icons-action' ;
17+ import SLDS_ICONS_CUSTOM from './slds-icons-custom' ;
18+ import SLDS_ICONS_DOCTYPE from './slds-icons-doctype' ;
19+ import SLDS_ICONS_STANDARD from './slds-icons-standard' ;
1620
1721module . exports = React . createClass ( {
1822
1923 getDefaultProps ( ) {
2024 return {
21- name :'announcenent'
25+ name :'announcenent' ,
26+ category :'utility'
2227 } ;
2328 } ,
2429
25- getPaths ( data ) {
26- if ( data instanceof Array ) {
27- return data . map ( ( item ) => {
30+ getPaths ( paths ) {
31+ if ( paths instanceof Array ) {
32+ return paths . map ( ( item ) => {
2833 return < path { ...item } /> ;
2934 } ) ;
3035 }
31- return < path { ...data } /> ;
36+ return < path { ...paths } /> ;
3237 } ,
3338
34- getSVG ( name ) {
35- const data = SLDS_ICONS_UTIL [ name . toLowerCase ( ) ] ;
36- return < svg { ...this . props } viewBox = { SLDS_ICONS_UTIL . viewBox } > { this . getPaths ( data ) } </ svg > ;
39+ getCircles ( circles ) {
40+ if ( circles instanceof Array ) {
41+ return circles . map ( ( item ) => {
42+ return < circle { ...item } /> ;
43+ } ) ;
44+ }
45+ return < circle { ...circles } /> ;
46+ } ,
47+
48+ getEllipses ( ellipses ) {
49+ if ( ellipses instanceof Array ) {
50+ return ellipses . map ( ( item ) => {
51+ return < ellipse { ...item } /> ;
52+ } ) ;
53+ }
54+ return < ellipse { ...ellipses } /> ;
55+ } ,
56+
57+ getGroups ( groups ) {
58+ if ( groups instanceof Array ) {
59+ return groups . map ( ( item ) => {
60+ return < g > { this . getShapes ( item ) } </ g > ;
61+ } ) ;
62+ }
63+ return < g > { this . getShapes ( groups ) } </ g > ;
64+ } ,
65+
66+ getShapes ( data ) {
67+ var shapes = [ ] ;
68+ if ( data . g ) {
69+ shapes . push ( this . getGroups ( data . g ) ) ;
70+ }
71+ if ( data . ellipse ) {
72+ shapes . push ( this . getEllipses ( data . ellipse ) ) ;
73+ }
74+ if ( data . circle ) {
75+ shapes . push ( this . getCircles ( data . circle ) ) ;
76+ }
77+ if ( data . path ) {
78+ shapes . push ( this . getPaths ( data . path ) ) ;
79+ }
80+ return shapes ;
81+ } ,
82+
83+ getSVG ( name , category ) {
84+ var data ;
85+ var viewBox ;
86+ switch ( category ) {
87+ case 'utility' :
88+ data = SLDS_ICONS_UTILITY [ name . toLowerCase ( ) ] ;
89+ viewBox = SLDS_ICONS_UTILITY . viewBox ;
90+ break ;
91+ case 'action' :
92+ data = SLDS_ICONS_ACTION [ name . toLowerCase ( ) ] ;
93+ viewBox = SLDS_ICONS_ACTION . viewBox ;
94+ break ;
95+ case 'custom' :
96+ data = SLDS_ICONS_CUSTOM [ name . toLowerCase ( ) ] ;
97+ viewBox = SLDS_ICONS_CUSTOM . viewBox ;
98+ break ;
99+ case 'doctype' :
100+ data = SLDS_ICONS_DOCTYPE [ name . toLowerCase ( ) ] ;
101+ viewBox = SLDS_ICONS_DOCTYPE . viewBox ;
102+ break ;
103+ case 'standard' :
104+ data = SLDS_ICONS_STANDARD [ name . toLowerCase ( ) ] ;
105+ viewBox = SLDS_ICONS_STANDARD . viewBox ;
106+ break ;
107+ default :
108+ data = SLDS_ICONS_UTILITY [ name . toLowerCase ( ) ] ;
109+ viewBox = SLDS_ICONS_UTILITY . viewBox ;
110+ break ;
111+ }
112+ return < svg { ...this . props } viewBox = { viewBox } > { this . getShapes ( data ) } </ svg > ;
37113 } ,
38114
39115 render ( ) {
40116 return (
41- this . getSVG ( this . props . name )
117+ this . getSVG ( this . props . name , this . props . category )
42118 ) ;
43119 }
44120} ) ;
0 commit comments