11//@flow
22import * as React from 'react'
33
4- import Wrap from './Wrap'
4+ import Wrap , { defaultProps } from './Wrap'
55// Stylized
6- import FacebookStyle from './stylized/FacebookStyle'
7- import InstagramStyle from './stylized/InstagramStyle'
8- import CodeStyle from './stylized/CodeStyle'
9- import ListStyle from './stylized/ListStyle'
10- import BulletListStyle from './stylized/BulletListStyle'
6+ export { default as Facebook } from './stylized/FacebookStyle'
7+ export { default as Instagram } from './stylized/InstagramStyle'
8+ export { default as Code } from './stylized/CodeStyle'
9+ export { default as List } from './stylized/ListStyle'
10+ export { default as BulletList } from './stylized/BulletListStyle'
1111
1212export type Props = {
1313 style : { [ key : string ] : any } ,
@@ -22,38 +22,11 @@ export type Props = {
2222}
2323
2424const ContentLoader = ( props : Props ) => {
25- if ( props . children ) {
26- return < Wrap { ...props } > { props . children } </ Wrap >
27- }
28-
29- switch ( props . type . toLowerCase ( ) ) {
30- case 'instagram' :
31- return < InstagramStyle { ...props } />
32-
33- case 'code' :
34- return < CodeStyle { ...props } />
35-
36- case 'list' :
37- return < ListStyle { ...props } />
38-
39- case 'bullet-list' :
40- return < BulletListStyle { ...props } />
41-
42- default :
43- case 'facebook' :
44- return < FacebookStyle { ...props } />
45- }
25+ const mergedProps = { ...defaultProps , ...props }
26+ const children = props . children
27+ ? props . children
28+ : < rect x = "0" y = "0" rx = "5" ry = "5" width = { mergedProps . width } height = { mergedProps . height } />
29+ return < Wrap { ...mergedProps } > { children } </ Wrap >
4630}
4731
48- ContentLoader . defaultProps = {
49- type : 'facebook' ,
50- speed : 2 ,
51- width : 400 ,
52- height : 130 ,
53- primaryColor : '#f0f0f0' ,
54- secondaryColor : '#e0e0e0' ,
55- preserveAspectRatio : 'xMidYMid meet' ,
56- className : '' ,
57- } ;
58-
5932export default ContentLoader
0 commit comments