Skip to content

Commit

Permalink
Merge pull request #2134 from oliviertassinari/app-bar
Browse files Browse the repository at this point in the history
[AppBar] Add an example of a clickable title
  • Loading branch information
oliviertassinari committed Nov 12, 2015
2 parents c58f120 + b669d99 commit 9879f09
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion docs/src/app/components/pages/components/app-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ const IconMenu = require('menus/icon-menu');
const MenuItem = require('menus/menu-item');
const MoreVertIcon = require('svg-icons/navigation/more-vert');

const styles = {
title: {
cursor: 'pointer',
},
};

export default class AppBarPage extends React.Component {

constructor(props) {
Expand Down Expand Up @@ -136,7 +142,7 @@ export default class AppBarPage extends React.Component {
iconClassNameRight="muidocs-icon-navigation-expand-more" />
<br />
<AppBar
title="Title"
title={<span style={styles.title} onTouchTap={this._onTouchTap}>Title</span>}
iconElementLeft={<IconButton><NavigationClose /></IconButton>}
iconElementRight={<FlatButton label="Save" />} />
<br />
Expand All @@ -157,4 +163,8 @@ export default class AppBarPage extends React.Component {
);
}

_onTouchTap() {
alert('onTouchTap triggered on the title component');
}

}
2 changes: 1 addition & 1 deletion docs/src/app/components/raw-code/app-bar-code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
iconClassNameRight="muidocs-icon-navigation-expand-more" />

<AppBar
title="Title"
title={<span>Title</span>}
iconElementLeft={<IconButton><NavigationClose /></IconButton>}
iconElementRight={<FlatButton label="Save" />} />

Expand Down
2 changes: 1 addition & 1 deletion src/app-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const AppBar = React.createClass({
// If not, just use it as a node.
titleElement = typeof title === 'string' || title instanceof String ?
<h1 onTouchTap={this._onTitleTouchTap} style={this.prepareStyles(styles.title, styles.mainElement)}>{title}</h1> :
<div onTouchTap={this._onTitleTouchTap} style={this.prepareStyles(styles.mainElement)}>{title}</div>;
<div onTouchTap={this._onTitleTouchTap} style={this.prepareStyles(styles.title, styles.mainElement)}>{title}</div>;
}

if (showMenuIconButton) {
Expand Down

0 comments on commit 9879f09

Please sign in to comment.