Skip to content

Commit 13f395d

Browse files
committed
[added] bsStyle prop support for Modal to set the header color
1 parent f26e39f commit 13f395d

File tree

6 files changed

+28
-5
lines changed

6 files changed

+28
-5
lines changed

docs/examples/ModalContained.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
var ContainedModal = React.createClass({
1414
render: function() {
1515
return (
16-
<Modal {...this.props} title='Contained Modal' animation>
16+
<Modal {...this.props} bsStyle="primary" title='Contained Modal' animation>
1717
<div className="modal-body">
1818
Elit est explicabo ipsum eaque dolorem blanditiis doloribus sed id ipsam, beatae, rem fuga id earum? Inventore et facilis obcaecati.
1919
</div>

docs/examples/ModalOverlayMixin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var CustomModalTrigger = React.createClass({
2828
}
2929

3030
return (
31-
<Modal title="Modal heading" onRequestHide={this.handleToggle}>
31+
<Modal bsStyle="primary" title="Modal heading" onRequestHide={this.handleToggle}>
3232
<div className="modal-body">
3333
This modal is controlled by our custom trigger component.
3434
</div>

docs/examples/ModalStatic.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ function handleHide() {
55
var modalInstance = (
66
<div className="static-modal">
77
<Modal title="Modal title"
8+
bsStyle="primary"
89
backdrop={false}
910
animation={false}
1011
container={mountNode}

docs/examples/ModalTrigger.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var MyModal = React.createClass({
22
render: function() {
33
return (
4-
<Modal {...this.props} title="Modal heading" animation={false}>
4+
<Modal {...this.props} bsStyle="primary" title="Modal heading" animation={false}>
55
<div className="modal-body">
66
<h4>Text in a modal</h4>
77
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula.</p>

src/Modal.jsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ var Modal = React.createClass({
5858
onClick={this.props.backdrop === true ? this.handleBackdropClick : null}
5959
ref="modal">
6060
<div className={classSet(dialogClasses)}>
61-
<div className="modal-content">
61+
<div className="modal-content" style={{overflow: 'hidden'}}>
6262
{this.props.title ? this.renderHeader() : null}
6363
{this.props.children}
6464
</div>
@@ -97,8 +97,17 @@ var Modal = React.createClass({
9797
);
9898
}
9999

100+
var style = this.props.bsStyle;
101+
var classes = {
102+
'modal-header': true
103+
};
104+
classes['bg-' + style] = style;
105+
classes['text-' + style] = style;
106+
107+
var className = classSet(classes);
108+
100109
return (
101-
<div className="modal-header">
110+
<div className={className}>
102111
{closeButton}
103112
{this.renderTitle()}
104113
</div>

test/ModalSpec.jsx

+13
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,17 @@ describe('Modal', function () {
8585
assert.ok(dialog.className.match(/\bmodal-sm\b/));
8686
});
8787

88+
it('Should pass bsStyle to the header', function () {
89+
var noOp = function () {};
90+
var instance = ReactTestUtils.renderIntoDocument(
91+
<Modal bsStyle='danger' title="Title" onRequestHide={noOp}>
92+
<strong>Message</strong>
93+
</Modal>
94+
);
95+
96+
var header = instance.getDOMNode().getElementsByClassName('modal-header')[0];
97+
assert.ok(header.className.match(/\bbg-danger\b/));
98+
assert.ok(header.className.match(/\btext-danger\b/));
99+
});
100+
88101
});

0 commit comments

Comments
 (0)