diff --git a/common/changes/office-ui-fabric-react/split-button-divider_2017-09-08-00-37.json b/common/changes/office-ui-fabric-react/split-button-divider_2017-09-08-00-37.json new file mode 100644 index 0000000000000..bc638fca7b354 --- /dev/null +++ b/common/changes/office-ui-fabric-react/split-button-divider_2017-09-08-00-37.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "office-ui-fabric-react", + "comment": "Button: Add support for dividers in split buttons", + "type": "patch" + } + ], + "packageName": "office-ui-fabric-react", + "email": "christianjordangonzalez@gmail.com" +} \ No newline at end of file diff --git a/packages/office-ui-fabric-react/src/components/Button/BaseButton.tsx b/packages/office-ui-fabric-react/src/components/Button/BaseButton.tsx index 8e0cd4a9d9395..dcdc77f75dbe5 100644 --- a/packages/office-ui-fabric-react/src/components/Button/BaseButton.tsx +++ b/packages/office-ui-fabric-react/src/components/Button/BaseButton.tsx @@ -17,7 +17,7 @@ import { DirectionalHint } from '../../common/DirectionalHint'; import { ContextualMenu, IContextualMenuProps } from '../../ContextualMenu'; import { IButtonProps, IButton } from './Button.Props'; import { IButtonClassNames, getClassNames } from './BaseButton.classNames'; -import { getClassNames as getSplitButtonClassNames } from './SplitButton/SplitButton.classNames'; +import { getClassNames as getSplitButtonClassNames, ISplitButtonClassNames } from './SplitButton/SplitButton.classNames'; export interface IBaseButtonProps extends IButtonProps { baseClassName?: string; @@ -360,9 +360,12 @@ export class BaseButton extends BaseComponent + { this._onRenderContent(tag, buttonProps) } - { this._onRenderSplitButtonMenuButton() } + { this._onRenderSplitButtonDivider(classNames) } + { this._onRenderSplitButtonMenuButton(classNames) } ); } - private _onRenderSplitButtonMenuButton(): JSX.Element { + private _onRenderSplitButtonDivider(classNames: ISplitButtonClassNames | undefined): JSX.Element | null { + if (classNames && classNames.divider) { + return ; + } + return null; + } + + private _onRenderSplitButtonMenuButton(classNames: ISplitButtonClassNames | undefined): JSX.Element { let { menuIconName, - menuIconProps, - styles, - disabled, - checked + menuIconProps } = this.props; if (menuIconProps === undefined) { @@ -399,8 +408,6 @@ export class BaseButton extends BaseComponent { + return { + splitButtonMenuButton: { backgroundColor: 'white', width: '10px' }, + splitButtonMenuIcon: { fontSize: '7px' }, + splitButtonDivider: { borderLeft: '1px solid #c8c8c8' } + }; +}); \ No newline at end of file diff --git a/packages/office-ui-fabric-react/src/components/Button/examples/Button.Split.Example.tsx b/packages/office-ui-fabric-react/src/components/Button/examples/Button.Split.Example.tsx index 5c3c4a57aa8ef..4f235f9022131 100644 --- a/packages/office-ui-fabric-react/src/components/Button/examples/Button.Split.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/Button/examples/Button.Split.Example.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; -import { DefaultButton, IconButton, IButtonProps, IButtonStyles } from 'office-ui-fabric-react/lib/Button'; +import { DefaultButton, IconButton, IButtonProps } from 'office-ui-fabric-react/lib/Button'; import { Label } from 'office-ui-fabric-react/lib/Label'; +import { getCustomSplitButtonStyles } from './Button.Split.Example.styles'; export class ButtonSplitExample extends React.Component { public constructor() { @@ -47,7 +48,7 @@ export class ButtonSplitCustomExample extends React.Component public render() { let { disabled, checked } = this.props; - const style: IButtonStyles = { splitButtonMenuButton: { backgroundColor: 'white', width: '10px' }, splitButtonMenuIcon: { fontSize: '7px' } }; + const customSplitButtonStyles = getCustomSplitButtonStyles(); return (
@@ -60,7 +61,7 @@ export class ButtonSplitCustomExample extends React.Component text='Create account' onClick={ () => alert('Clicked') } split={ true } - styles={ style } + styles={ customSplitButtonStyles } menuProps={ { items: [ {