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] make IconMenu to render correctly #1588

Merged
merged 1 commit into from
Sep 30, 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
17 changes: 16 additions & 1 deletion docs/src/app/components/pages/components/app-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ let FlatButton = require('flat-button');
let ComponentDoc = require('../../component-doc');
let CodeExample = require('../../code-example/code-example');
let Code = require('app-bar-code');

const IconMenu = require('menus/icon-menu');
const MenuItem = require('menus/menu-item');
const MoreVertIcon = require('svg-icons/navigation/more-vert');

class AppBarPage extends React.Component {

Expand Down Expand Up @@ -120,6 +122,19 @@ class AppBarPage extends React.Component {
title="Title"
iconElementLeft={<IconButton><NavigationClose /></IconButton>}
iconElementRight={<FlatButton label="Save" />} />
<br />
<AppBar
title="Title"
iconElementLeft={<IconButton><NavigationClose /></IconButton>}
iconElementRight={
<IconMenu iconButtonElement={
<IconButton><MoreVertIcon /></IconButton>
}>
<MenuItem primaryText="Refresh" />
<MenuItem primaryText="Help" />
<MenuItem primaryText="Sign out" />
</IconMenu>
} />
</CodeExample>
</ComponentDoc>
);
Expand Down
6 changes: 6 additions & 0 deletions docs/src/app/components/pages/components/icon-menus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ class IconMenus extends React.Component {
header: 'default: false',
desc: 'Indicates if the menu should render with compact desktop styles.'
},
{
name: 'iconStyle',
type: 'object',
header: 'optional',
desc: 'The style object to use to override underlying icon style.'
},
{
name: 'iconButtonElement',
type: 'element: IconButton',
Expand Down
15 changes: 14 additions & 1 deletion docs/src/app/components/raw-code/app-bar-code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,17 @@
<AppBar
title="Title"
iconElementLeft={<IconButton><NavigationClose /></IconButton>}
iconElementRight={<FlatButton label="Save" />} />;
iconElementRight={<FlatButton label="Save" />} />

<AppBar
title="Title"
iconElementLeft={<IconButton><NavigationClose /></IconButton>}
iconElementRight={
<IconMenu iconButtonElement={
<IconButton><MoreVertIcon /></IconButton>
}>
<MenuItem primaryText="Refresh" />
<MenuItem primaryText="Help" />
<MenuItem primaryText="Sign out" />
</IconMenu>
} />
1 change: 1 addition & 0 deletions src/app-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ const AppBar = React.createClass({
let iconElementRight = props.iconElementRight;

switch (iconElementRight.type.displayName) {
case 'IconMenu':
case 'IconButton':
iconElementRight = React.cloneElement(iconElementRight, {
iconStyle: this.mergeAndPrefix(styles.iconButton.iconStyle),
Expand Down
3 changes: 3 additions & 0 deletions src/menus/icon-menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const IconMenu = React.createClass({
propTypes: {
closeOnItemTouchTap: React.PropTypes.bool,
iconButtonElement: React.PropTypes.element.isRequired,
iconStyle: React.PropTypes.object,
openDirection: PropTypes.corners,
onItemTouchTap: React.PropTypes.func,
onKeyboardFocus: React.PropTypes.func,
Expand Down Expand Up @@ -85,6 +86,7 @@ const IconMenu = React.createClass({
let {
closeOnItemTouchTap,
iconButtonElement,
iconStyle,
openDirection,
onItemTouchTap,
onKeyboardFocus,
Expand Down Expand Up @@ -121,6 +123,7 @@ const IconMenu = React.createClass({

let iconButton = React.cloneElement(iconButtonElement, {
onKeyboardFocus: this.props.onKeyboardFocus,
iconStyle: this.mergeStyles(iconStyle, iconButtonElement.props.iconStyle),
onTouchTap: (e) => {
this.open(Events.isKeyboard(e));
if (iconButtonElement.props.onTouchTap) iconButtonElement.props.onTouchTap(e);
Expand Down