Skip to content

Commit

Permalink
Merge pull request #1172 from OfficeDev/contextual-menu/item-styles
Browse files Browse the repository at this point in the history
Add style property to IContextualMenuItem
  • Loading branch information
MLoughry authored Mar 3, 2017
2 parents 6831a4e + 11e9fb5 commit c3817c9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions common/changes/contextual-menu-item-styles_2017-03-03-22-07.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Contextual Menu: allow developers to specify inline styles for menu items",
"type": "minor"
}
],
"email": "miclo@microsoft.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ export interface IContextualMenuItem {
*/
className?: string;

/**
* Additional styles to apply to the menu item
* @defaultvalue undefined
*/
style?: React.CSSProperties;

/**
* Optional accessibility label (aria-label) attribute that will be stamped on to the element.
* If none is specified, the arai-label attribute will contain the item name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext

private _renderHeaderMenuItem(item: IContextualMenuItem, index: number, hasCheckmarks: boolean, hasIcons: boolean): React.ReactNode {
return (
<div className={ css('ms-ContextualMenu-header', styles.header) }>
<div className={ css('ms-ContextualMenu-header', styles.header) } style={ item.style }>
{ this._renderMenuItemChildren(item, index, hasCheckmarks, hasIcons) }
</div>);
}
Expand All @@ -308,6 +308,7 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext
styles.link,
(item.isDisabled || item.disabled) && 'is-disabled') }
role='menuitem'
style={ item.style }
onClick={ this._onAnchorClick.bind(this, item) }>
{ (hasIcons) ? (
this._renderIcon(item)
Expand Down Expand Up @@ -346,7 +347,8 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext
title: item.title,
'aria-label': ariaLabel,
'aria-haspopup': hasSubmenuItems(item) ? true : null,
'aria-owns': item.key === expandedMenuItemKey ? subMenuId : null
'aria-owns': item.key === expandedMenuItemKey ? subMenuId : null,
style: item.style,
};

return React.createElement(
Expand Down

0 comments on commit c3817c9

Please sign in to comment.