@@ -2,7 +2,8 @@ var React = require('react');
2
2
var div = React . DOM . div ;
3
3
var focusManager = require ( '../helpers/focusManager' ) ;
4
4
var scopeTab = require ( '../helpers/scopeTab' ) ;
5
- var cx = require ( 'classnames' ) ;
5
+ var Assign = require ( 'lodash.assign' ) ;
6
+
6
7
7
8
// so that our CSS is statically analyzable
8
9
var CLASS_NAMES = {
@@ -18,7 +19,31 @@ var CLASS_NAMES = {
18
19
}
19
20
} ;
20
21
21
- var OVERLAY_STYLES = { position : 'fixed' , left : 0 , right : 0 , top : 0 , bottom : 0 } ;
22
+ var defaultStyles = {
23
+ overlay : {
24
+ position : 'fixed' ,
25
+ top : 0 ,
26
+ left : 0 ,
27
+ right : 0 ,
28
+ bottom : 0 ,
29
+ backgroundColor : 'rgba(255, 255, 255, 0.75)'
30
+ } ,
31
+ content : {
32
+ position : 'absolute' ,
33
+ top : '40px' ,
34
+ left : '40px' ,
35
+ right : '40px' ,
36
+ bottom : '40px' ,
37
+ border : '1px solid #ccc' ,
38
+ background : '#fff' ,
39
+ overflow : 'auto' ,
40
+ WebkitOverflowScrolling : 'touch' ,
41
+ borderRadius : '4px' ,
42
+ outline : 'none' ,
43
+ padding : '20px'
44
+
45
+ }
46
+ } ;
22
47
23
48
function stopPropagation ( event ) {
24
49
event . stopPropagation ( ) ;
@@ -28,6 +53,15 @@ var ModalPortal = module.exports = React.createClass({
28
53
29
54
displayName : 'ModalPortal' ,
30
55
56
+ getDefaultProps : function ( ) {
57
+ return {
58
+ style : {
59
+ overlay : { } ,
60
+ content : { }
61
+ }
62
+ }
63
+ } ,
64
+
31
65
getInitialState : function ( ) {
32
66
return {
33
67
afterOpen : false ,
@@ -132,27 +166,27 @@ var ModalPortal = module.exports = React.createClass({
132
166
return ! this . props . isOpen && ! this . state . beforeClose ;
133
167
} ,
134
168
135
- buildClassName : function ( which ) {
169
+ buildClassName : function ( which , additional ) {
136
170
var className = CLASS_NAMES [ which ] . base ;
137
171
if ( this . state . afterOpen )
138
172
className += ' ' + CLASS_NAMES [ which ] . afterOpen ;
139
173
if ( this . state . beforeClose )
140
174
className += ' ' + CLASS_NAMES [ which ] . beforeClose ;
141
- return className ;
175
+ return additional ? className + ' ' + additional : className ;
142
176
} ,
143
177
144
178
render : function ( ) {
145
179
return this . shouldBeClosed ( ) ? div ( ) : (
146
180
div ( {
147
181
ref : "overlay" ,
148
- className : cx ( this . buildClassName ( 'overlay' ) , this . props . overlayClassName ) ,
149
- style : OVERLAY_STYLES ,
182
+ className : this . buildClassName ( 'overlay' , this . props . overlayClassName ) ,
183
+ style : Assign ( { } , defaultStyles . overlay , this . props . style . overlay || { } ) ,
150
184
onClick : this . handleOverlayClick
151
185
} ,
152
186
div ( {
153
187
ref : "content" ,
154
- style : this . props . style ,
155
- className : cx ( this . buildClassName ( 'content' ) , this . props . className ) ,
188
+ style : Assign ( { } , defaultStyles . content , this . props . style . content || { } ) ,
189
+ className : this . buildClassName ( 'content' , this . props . className ) ,
156
190
tabIndex : "-1" ,
157
191
onClick : stopPropagation ,
158
192
onKeyDown : this . handleKeyDown
0 commit comments