@@ -24,72 +24,40 @@ export type Props = {
2424 className : string ,
2525}
2626
27- type State = {
28- style : { [ key : string ] : any } ,
29- type : string ,
30- speed : number ,
31- width : number ,
32- height : number ,
33- primaryColor : string ,
34- secondaryColor : string ,
35- preserveAspectRatio : string ,
36- className : string ,
37- }
38-
39- class ContentLoader extends React . Component < Props , State > {
40- static defaultProps = {
41- type : 'facebook' ,
42- speed : 2 ,
43- width : 400 ,
44- height : 130 ,
45- primaryColor : '#f0f0f0' ,
46- secondaryColor : '#e0e0e0' ,
47- preserveAspectRatio : 'xMidYMid meet' ,
48- className : '' ,
49- }
50-
51- constructor ( props : Props ) {
52- super ( props )
53-
54- this . state = {
55- style : props . style ,
56- type : props . type ,
57- speed : props . speed ,
58- width : props . width ,
59- height : props . height ,
60- primaryColor : props . primaryColor ,
61- secondaryColor : props . secondaryColor ,
62- preserveAspectRatio : props . preserveAspectRatio ,
63- className : props . className ,
64- }
27+ const ContentLoader = ( props : Props ) => {
28+ if ( props . children ) {
29+ return < Wrap { ...props } > { props . children } </ Wrap >
6530 }
6631
67- render ( ) {
68- if ( this . props . children ) {
69- return < Wrap { ...this . state } > { this . props . children } </ Wrap >
70- }
32+ switch ( props . type . toLowerCase ( ) ) {
33+ case 'instagram' :
34+ return < InstagramStyle { ...props } />
7135
72- if ( ! this . props . children ) {
73- switch ( this . state . type . toLowerCase ( ) ) {
74- case 'instagram' :
75- return < InstagramStyle { ...this . state } />
36+ case 'code' :
37+ return < CodeStyle { ...props } />
7638
77- case 'code ' :
78- return < CodeStyle { ...this . state } />
39+ case 'list ' :
40+ return < ListStyle { ...props } />
7941
80- case 'list' :
81- return < ListStyle { ...this . state } />
42+ case 'bullet- list' :
43+ return < BulletListStyle { ...props } />
8244
83- case 'bullet-list' :
84- return < BulletListStyle { ...this . state } />
85-
86- default :
87- case 'facebook' :
88- return < FacebookStyle { ...this . state } />
89- }
90- }
45+ default :
46+ case 'facebook' :
47+ return < FacebookStyle { ...props } />
9148 }
9249}
9350
51+ ContentLoader . defaultProps = {
52+ type : 'facebook' ,
53+ speed : 2 ,
54+ width : 400 ,
55+ height : 130 ,
56+ primaryColor : '#f0f0f0' ,
57+ secondaryColor : '#e0e0e0' ,
58+ preserveAspectRatio : 'xMidYMid meet' ,
59+ className : '' ,
60+ } ;
61+
9462export default ContentLoader
9563export { Rect , Circle }
0 commit comments