forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdialog.jsx
82 lines (66 loc) · 1.74 KB
/
dialog.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
var React = require('react');
var StylePropable = require('./mixins/style-propable');
var Spacing = require('./styles/spacing');
var DialogWindow = require('./dialog-window');
var Dialog = React.createClass({
mixins: [StylePropable],
contextTypes: {
muiTheme: React.PropTypes.object
},
propTypes: {
title: React.PropTypes.node,
contentInnerStyle: React.PropTypes.object,
},
getStyles: function() {
var gutter = Spacing.desktopGutter + 'px ';
var styles = {
title: {
margin: 0,
padding: gutter + gutter + '0 ' + gutter,
color: this.context.muiTheme.palette.textColor,
fontSize: '24px',
lineHeight: '32px',
fontWeight: '400',
},
content: {
padding: Spacing.desktopGutter
}
};
return styles;
},
render: function() {
var {
className,
contentInnerStyle,
...other
} = this.props;
var styles = this.getStyles();
var title;
if (this.props.title) {
// If the title is a string, wrap in an h3 tag.
// If not, just use it as a node.
title = Object.prototype.toString.call(this.props.title) === '[object String]' ?
<h3 style={styles.title}>{this.props.title}</h3> :
this.props.title;
}
return (
<DialogWindow
{...other}
ref="dialogWindow"
className={className}
style={this.props.style}>
{title}
<div ref="dialogContent" style={this.mergeAndPrefix(styles.content, contentInnerStyle)}>
{this.props.children}
</div>
</DialogWindow>
);
},
dismiss: function() {
this.refs.dialogWindow.dismiss();
},
show: function() {
this.refs.dialogWindow.show();
}
});
module.exports = Dialog;