forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp-canvas.jsx
45 lines (36 loc) · 990 Bytes
/
app-canvas.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
let React = require('react');
let StylePropable = require('./mixins/style-propable');
let AppCanvas = React.createClass({
mixins: [StylePropable],
contextTypes: {
muiTheme: React.PropTypes.object,
},
render() {
let styles = {
height: '100%',
backgroundColor: this.context.muiTheme.palette.canvasColor,
WebkitFontSmoothing: 'antialiased',
};
let newChildren = React.Children.map(this.props.children, (currentChild) => {
if (!currentChild) { // If undefined, skip it
return null;
}
switch (currentChild.type.displayName) {
case 'AppBar' :
return React.cloneElement(currentChild, {
style: this.mergeStyles({
position: 'fixed',
}, currentChild.props.style),
});
default:
return currentChild;
}
}, this);
return (
<div style={styles}>
{newChildren}
</div>
);
},
});
module.exports = AppCanvas;