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

Add style property to IContextualMenuItem #1172

Merged
merged 2 commits into from
Mar 3, 2017
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
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