1
1
React = require ' react'
2
2
PropTypes = React .PropTypes
3
3
componentWidthMixin = require ' react-component-width-mixin'
4
+ assign = require ' object-assign'
4
5
5
6
calculateLayout = require ' ./calculate_layout'
6
7
@@ -16,13 +17,17 @@ module.exports = React.createClass
16
17
marginBottom : PropTypes .number
17
18
targetWidth : PropTypes .number
18
19
widthHeightRatio : PropTypes .number
20
+ galleryStyle : PropTypes .object
21
+ componentStyle : PropTypes .object
19
22
20
23
getDefaultProps : ->
21
24
margin : 10
22
25
noMarginBottomOnLastRow : false
23
26
targetWidth : 200
24
27
widthHeightRatio : 1
25
28
disableServerRender : false
29
+ galleryStyle : {}
30
+ componentStyle : {}
26
31
27
32
render : ->
28
33
# If we don't know the component width, there's nothing we can do.
@@ -34,7 +39,14 @@ module.exports = React.createClass
34
39
else
35
40
[componentWidth , componentsPerRow ] = calculateLayout (@props , @state )
36
41
return (
37
- <div className = " component-gallery #{ @props .className } " style = {{overflow : " hidden" }}>
42
+ <div
43
+ className = " component-gallery #{ @props .className } "
44
+ style = {assign (
45
+ {},
46
+ {overflow : " hidden" },
47
+ @props .galleryStyle
48
+ )}
49
+ >
38
50
{React .Children .map (@props .children , (child , i ) =>
39
51
marginBottom = @props .margin
40
52
@@ -59,16 +71,20 @@ module.exports = React.createClass
59
71
return (
60
72
React .DOM .div ({
61
73
className : " component-wrapper"
62
- style : {
63
- width : " #{ componentWidth} px"
64
- height : " #{ componentWidth* @props .widthHeightRatio } px"
65
- display : " inline-block"
66
- marginRight : " #{ marginRight} px"
67
- marginBottom : " #{ marginBottom} px"
68
- overflow : " hidden"
69
- position : " relative"
70
- " verticalAlign" : " top"
71
- }
74
+ style : assign (
75
+ {},
76
+ {
77
+ width : " #{ componentWidth} px"
78
+ height : " #{ componentWidth* @props .widthHeightRatio } px"
79
+ display : " inline-block"
80
+ marginRight : " #{ marginRight} px"
81
+ marginBottom : " #{ marginBottom} px"
82
+ overflow : " hidden"
83
+ position : " relative"
84
+ verticalAlign : " top"
85
+ },
86
+ @props .componentStyle
87
+ )
72
88
}, child)
73
89
)
74
90
)}
0 commit comments