Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[appbar] allow override of the style props in AppCanvas #903

Merged
merged 1 commit into from
Jun 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/app-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ let AppBar = React.createClass({
onLeftIconButtonTouchTap: React.PropTypes.func,
onRightIconButtonTouchTap: React.PropTypes.func,
showMenuIconButton: React.PropTypes.bool,
style: React.PropTypes.object,
iconClassNameLeft: React.PropTypes.string,
iconClassNameRight: React.PropTypes.string,
iconElementLeft: React.PropTypes.element,
iconElementRight: React.PropTypes.element,
iconStyleRight: React.PropTypes.object,
title : React.PropTypes.node,
title: React.PropTypes.node,
zDepth: React.PropTypes.number,
},

Expand All @@ -32,7 +33,7 @@ let AppBar = React.createClass({
showMenuIconButton: true,
title: '',
zDepth: 1
}
};
},

componentDidMount: function() {
Expand Down
9 changes: 6 additions & 3 deletions src/app-canvas.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
let React = require('react');
let StylePropable = require('./mixins/style-propable');

let AppCanvas = React.createClass({

mixins: [StylePropable],

contextTypes: {
muiTheme: React.PropTypes.object
},
Expand All @@ -16,15 +19,15 @@ let AppCanvas = React.createClass({

let newChildren = React.Children.map(this.props.children, function(currentChild) {
if (!currentChild) { // If undefined, skip it
return;
return null;
}

switch (currentChild.type.displayName) {
case 'AppBar' :
return React.cloneElement(currentChild, {
style: {
style: this.mergeStyles({
position: 'fixed',
}
}, currentChild.props.style)
});
default:
return currentChild;
Expand Down
6 changes: 4 additions & 2 deletions src/mixins/style-propable.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ module.exports = {
let args = Array.prototype.slice.call(arguments, 0);
let base = args[0];
for (let i = 1; i < args.length; i++) {
if (args[i]) base = Extend(base, args[i]);
if (args[i]) {
base = Extend(base, args[i]);
}
}
return base;
},
Expand All @@ -30,4 +32,4 @@ module.exports = {
let mergedStyles = this.mergeStyles.apply(this, arguments);
return AutoPrefix.all(mergedStyles);
},
}
};