File tree Expand file tree Collapse file tree 3 files changed +29
-6
lines changed Expand file tree Collapse file tree 3 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ const Modal = React.createClass({
126126
127127 getDefaultProps ( ) {
128128 return {
129+ bsClass : 'modal' ,
129130 show : false ,
130131 animation : true ,
131132 backdrop : true ,
@@ -203,12 +204,12 @@ const Modal = React.createClass({
203204 } ,
204205
205206 renderBackdrop ( modal ) {
206- let { animation } = this . props ;
207+ let { animation, bsClass } = this . props ;
207208 let duration = Modal . BACKDROP_TRANSITION_DURATION ;
208209
209210 let backdrop = (
210211 < div ref = "backdrop"
211- className = { classNames ( 'modal -backdrop' , { in : this . props . show && ! animation } ) }
212+ className = { classNames ( ` ${ bsClass } -backdrop` , { in : this . props . show && ! animation } ) }
212213 onClick = { this . handleBackdropClick }
213214 />
214215 ) ;
Original file line number Diff line number Diff line change @@ -32,10 +32,11 @@ const ModalDialog = React.createClass({
3232
3333 render ( ) {
3434 let modalStyle = { display : 'block' } ;
35+ let bsClass = this . props . bsClass ;
3536 let dialogClasses = this . getBsClassSet ( ) ;
3637
3738 delete dialogClasses . modal ;
38- dialogClasses [ 'modal -dialog' ] = true ;
39+ dialogClasses [ ` ${ bsClass } -dialog` ] = true ;
3940
4041 return (
4142 < div
@@ -44,10 +45,10 @@ const ModalDialog = React.createClass({
4445 tabIndex = "-1"
4546 role = "dialog"
4647 style = { modalStyle }
47- className = { classNames ( this . props . className , 'modal' ) }
48+ className = { classNames ( this . props . className , bsClass ) }
4849 >
4950 < div className = { classNames ( this . props . dialogClassName , dialogClasses ) } >
50- < div className = "modal -content" role = 'document' >
51+ < div className = { ` ${ bsClass } -content` } role = 'document' >
5152 { this . props . children }
5253 </ div >
5354 </ div >
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import ReactTestUtils from 'react/lib/ReactTestUtils' ;
33import Modal from '../src/Modal' ;
4- import { render } from './helpers' ;
4+ import { render , shouldWarn } from './helpers' ;
55
66describe ( 'Modal' , function ( ) {
77 let mountPoint ;
@@ -115,6 +115,27 @@ describe('Modal', function () {
115115 ReactTestUtils . Simulate . click ( button ) ;
116116 } ) ;
117117
118+ it ( 'Should use bsClass on the dialog' , function ( ) {
119+ let noOp = function ( ) { } ;
120+ let instance = render (
121+ < Modal show bsClass = 'mymodal' onHide = { noOp } >
122+ < strong > Message</ strong >
123+ </ Modal >
124+ , mountPoint ) ;
125+
126+ let dialog = React . findDOMNode ( instance . refs . dialog ) ;
127+ let backdrop = React . findDOMNode ( instance . refs . backdrop ) ;
128+
129+ assert . ok ( dialog . className . match ( / \b m y m o d a l \b / ) ) ;
130+ assert . ok ( dialog . children [ 0 ] . className . match ( / \b m y m o d a l - d i a l o g \b / ) ) ;
131+ assert . ok ( dialog . children [ 0 ] . children [ 0 ] . className . match ( / \b m y m o d a l - c o n t e n t \b / ) ) ;
132+
133+ assert . ok ( backdrop . className . match ( / \b m y m o d a l - b a c k d r o p \b / ) ) ;
134+
135+
136+ shouldWarn ( "Invalid prop 'bsClass' of value 'mymodal'" ) ;
137+ } ) ;
138+
118139 it ( 'Should pass bsSize to the dialog' , function ( ) {
119140 let noOp = function ( ) { } ;
120141 let instance = render (
You can’t perform that action at this time.
0 commit comments