Skip to content

Commit 6b00350

Browse files
committed
Merge pull request #474 from oliviertassinari/node
Dialog title: node instead of string
2 parents 641da77 + 00024b9 commit 6b00350

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

docs/src/app/components/pages/components/dialog.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var DialogPage = React.createClass({
99

1010
render: function() {
1111

12-
var code =
12+
var code =
1313
'//Standard Actions\n' +
1414
'var standardActions = [\n' +
1515
' { text: \'Cancel\' },\n' +
@@ -57,9 +57,9 @@ var DialogPage = React.createClass({
5757
},
5858
{
5959
name: 'title',
60-
type: 'string',
60+
type: 'node',
6161
header: 'optional',
62-
desc: 'The title string to display on the dialog.'
62+
desc: 'The title to display on the dialog. Could be number, string, element or an array containing these types.'
6363
}
6464
]
6565
},
@@ -160,4 +160,4 @@ var DialogPage = React.createClass({
160160

161161
});
162162

163-
module.exports = DialogPage;
163+
module.exports = DialogPage;

src/js/dialog.jsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,36 @@ var Dialog = React.createClass({
77
mixins: [Classable],
88

99
propTypes: {
10-
title: React.PropTypes.string
10+
title: React.PropTypes.node
1111
},
1212

1313
render: function() {
1414
var {
1515
className,
16-
title,
1716
...other
1817
} = this.props;
1918
var classes = this.getClasses('mui-dialog');
19+
var title;
20+
21+
if (this.props.title) {
22+
// If the title is a string, wrap in an h3 tag.
23+
// If not, just use it as a node.
24+
title = toString.call(this.props.title) === '[object String]' ?
25+
<h3 className="mui-dialog-title">{this.props.title}</h3> :
26+
this.props.title;
27+
}
2028

2129
return (
2230
<DialogWindow
2331
{...other}
2432
ref="dialogWindow"
2533
className={classes}>
2634

27-
<h3 className="mui-dialog-title">{this.props.title}</h3>
35+
{title}
2836
<div ref="dialogContent" className="mui-dialog-content">
2937
{this.props.children}
3038
</div>
31-
39+
3240
</DialogWindow>
3341
);
3442
},
@@ -43,4 +51,4 @@ var Dialog = React.createClass({
4351

4452
});
4553

46-
module.exports = Dialog;
54+
module.exports = Dialog;

0 commit comments

Comments
 (0)