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

[app-bar] allow to add children to app-bar #725

Merged
merged 1 commit into from
Jun 2, 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
19 changes: 13 additions & 6 deletions src/app-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var AppBar = React.createClass({
margin: 0,
paddingTop: 0,
letterSpacing: 0,
fontSize: '24px',
fontSize: 24,
fontWeight: Typography.fontWeightNormal,
color: themeVariables.textColor,
lineHeight: themeVariables.height + 'px'
Expand All @@ -85,7 +85,9 @@ var AppBar = React.createClass({
render: function() {
var styles = this.getStyles();

var title, menuElementLeft, menuElementRight;
var title;
var menuElementLeft;
var menuElementRight;
var iconRightStyle = this.mergeAndPrefix(styles.iconButton.style, {
float: 'right',
marginRight: -16,
Expand Down Expand Up @@ -147,16 +149,21 @@ var AppBar = React.createClass({
{menuElementLeft}
{title}
{menuElementRight}
{this.props.children}
</Paper>
);
},

_onLeftIconButtonTouchTap: function(e) {
if (this.props.onLeftIconButtonTouchTap) this.props.onLeftIconButtonTouchTap(e);
_onLeftIconButtonTouchTap: function(event) {
if (this.props.onLeftIconButtonTouchTap) {
this.props.onLeftIconButtonTouchTap(event);
}
},

_onRightIconButtonTouchTap: function(e) {
if (this.props.onRightIconButtonTouchTap) this.props.onRightIconButtonTouchTap(e);
_onRightIconButtonTouchTap: function(event) {
if (this.props.onRightIconButtonTouchTap) {
this.props.onRightIconButtonTouchTap(event);
}
}

});
Expand Down
15 changes: 7 additions & 8 deletions src/app-canvas.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var React = require('react');

var AppCanvas = React.createClass({

contextTypes: {
muiTheme: React.PropTypes.object
},
Expand All @@ -18,19 +18,18 @@ var AppCanvas = React.createClass({
WebkitFontSmoothing: 'antialiased'
};

var stylesAppBar = {
position: 'fixed',
height: this.context.muiTheme.component.appBar.height
};

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

switch (currentChild.type.displayName) {
case 'AppBar' :
return React.cloneElement(currentChild, {style: stylesAppBar});
case 'AppBar' :
return React.cloneElement(currentChild, {
style: {
position: 'fixed',
}
});
default:
return currentChild;
}
Expand Down