diff --git a/common/changes/tooltip-custom-render_2017-05-05-21-12.json b/common/changes/tooltip-custom-render_2017-05-05-21-12.json new file mode 100644 index 0000000000000..65fd11c3f6304 --- /dev/null +++ b/common/changes/tooltip-custom-render_2017-05-05-21-12.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "office-ui-fabric-react", + "comment": "Tooltip: Added custom content render function and exposed tooltip props to", + "type": "minor" + } + ], + "email": "micahgodbolt@gmail.com" +} \ No newline at end of file diff --git a/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.Props.ts b/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.Props.ts index 582e86cd76304..4d0f7054036a4 100644 --- a/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.Props.ts +++ b/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.Props.ts @@ -1,6 +1,7 @@ import * as React from 'react'; import { Tooltip } from './Tooltip'; import { ICalloutProps } from '../../Callout'; +import { IRenderFunction } from '../../Utilities'; import { DirectionalHint } from '../../common/DirectionalHint'; export interface ITooltip { @@ -27,6 +28,11 @@ export interface ITooltipProps extends React.HTMLProps */ content?: string; + /** + * Render function to populate content area + */ + onRenderContent?: IRenderFunction; + /** * Length of delay. Can be set to zero if you do not want a delay. * @default medium diff --git a/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.scss b/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.scss index a87c6ec778c02..2fc5607ef5aa4 100644 --- a/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.scss +++ b/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.scss @@ -17,10 +17,13 @@ } } -.subText { - margin: 0; +.content { font-size: $ms-font-size-s; color: $ms-color-neutralPrimary; word-wrap: break-word; overflow-wrap: break-word; +} + +.subText { + margin: 0; } \ No newline at end of file diff --git a/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.tsx b/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.tsx index 2dd3965cf7a1f..d98c08dfd2279 100644 --- a/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.tsx +++ b/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.tsx @@ -29,7 +29,15 @@ export class Tooltip extends BaseComponent { }; public render() { - let { targetElement, content, calloutProps, directionalHint, delay, id } = this.props; + const { + targetElement, + content, + calloutProps, + directionalHint, + delay, + id, + onRenderContent = this._onRenderContent + } = this.props; return ( { {...calloutProps} { ...getNativeProps(this.props, divProperties) } > -
- + ); } + + private _onRenderContent(props: ITooltipProps): JSX.Element { + return ( +

+ { props.content } +

+ ); + } } diff --git a/packages/office-ui-fabric-react/src/components/Tooltip/TooltipHost.Props.ts b/packages/office-ui-fabric-react/src/components/Tooltip/TooltipHost.Props.ts index 90cebe8ec02f9..3aa8a9db16fd8 100644 --- a/packages/office-ui-fabric-react/src/components/Tooltip/TooltipHost.Props.ts +++ b/packages/office-ui-fabric-react/src/components/Tooltip/TooltipHost.Props.ts @@ -1,6 +1,6 @@ import * as React from 'react'; import { TooltipHost } from './TooltipHost'; -import { TooltipDelay } from './Tooltip.Props'; +import { TooltipDelay, ITooltipProps } from './Tooltip.Props'; import { ICalloutProps } from '../../Callout'; import { DirectionalHint } from '../../common/DirectionalHint'; @@ -31,6 +31,11 @@ export interface ITooltipHostProps extends React.HTMLProps { @@ -24,12 +24,12 @@ export class TooltipPage extends React.Component { componentName='TooltipExample' exampleCards={ - + - - + + diff --git a/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Basic.Example.tsx b/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Basic.Example.tsx index 93fdc950b5f1c..8e849c64631d4 100644 --- a/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Basic.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Basic.Example.tsx @@ -12,7 +12,7 @@ export class TooltipBasicExample extends BaseComponent { public render() { return (
- + Hover Over Me
diff --git a/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Bottom.Example.tsx b/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Bottom.Example.tsx deleted file mode 100644 index e4d88025b83d6..0000000000000 --- a/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Bottom.Example.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* tslint:disable:no-unused-variable */ -import * as React from 'react'; -/* tslint:enable:no-unused-variable */ -import { BaseComponent } from 'office-ui-fabric-react/lib/Utilities'; -import { DefaultButton } from 'office-ui-fabric-react/lib/Button'; -import { - TooltipHost, - TooltipDelay, - DirectionalHint -} from 'office-ui-fabric-react/lib/Tooltip'; - -export class TooltipBottomExample extends BaseComponent { - - public render() { - return ( - - - - ); - } -} \ No newline at end of file diff --git a/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Custom.Example.tsx b/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Custom.Example.tsx new file mode 100644 index 0000000000000..85d195fc33d61 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Custom.Example.tsx @@ -0,0 +1,41 @@ +/* tslint:disable:no-unused-variable */ +import * as React from 'react'; +/* tslint:enable:no-unused-variable */ +import { BaseComponent } from 'office-ui-fabric-react/lib/Utilities'; +import { DefaultButton } from 'office-ui-fabric-react/lib/Button'; +import { + TooltipHost, + TooltipDelay, + DirectionalHint +} from 'office-ui-fabric-react/lib/Tooltip'; + +export class TooltipCustomExample extends BaseComponent { + + public render() { + return ( + { + return ( +
+
    +
  • 1. One
  • +
  • 2. Two
  • +
+
+ ); + } + } } + delay={ TooltipDelay.zero } + id='customID' + directionalHint={ DirectionalHint.bottomCenter } + > + +
+ ); + } +} \ No newline at end of file