office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
38 lines • 2.29 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { BaseComponent, getId } from 'office-ui-fabric-react/lib/Utilities';
import { DefaultButton } from 'office-ui-fabric-react/lib/Button';
import { TooltipHost, TooltipOverflowMode } from 'office-ui-fabric-react/lib/Tooltip';
var TooltipOverflowExample = /** @class */ (function (_super) {
tslib_1.__extends(TooltipOverflowExample, _super);
function TooltipOverflowExample(props) {
var _this = _super.call(this, props) || this;
_this.tooltipId = getId('text-tooltip');
_this.state = {
overflow: false,
isTooltipVisible: false
};
return _this;
}
// tslint:disable:jsx-no-lambda
TooltipOverflowExample.prototype.render = function () {
var _this = this;
return (React.createElement("div", null,
React.createElement(DefaultButton, { onClick: function () { return _this.setState({ overflow: !_this.state.overflow }); } }, "Toggle showing overflow"),
React.createElement("div", { style: {
marginTop: '40px'
} },
React.createElement("div", { style: {
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: this.state.overflow ? 'nowrap' : 'inherit',
width: this.state.overflow ? '200px' : 'auto',
border: '1px solid black'
} },
React.createElement(TooltipHost, { content: "This is the tooltip", id: this.tooltipId, overflowMode: TooltipOverflowMode.Parent, onTooltipToggle: function (isTooltipVisible) { return _this.setState({ isTooltipVisible: isTooltipVisible }); } },
React.createElement("span", { "aria-describedby": this.state.isTooltipVisible ? this.tooltipId : undefined }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec volutpat lectus ut magna sodales, sit amet accumsan arcu accumsan. Lorem ipsum dolor sit amet, consectetur adipiscing elit."))))));
};
return TooltipOverflowExample;
}(BaseComponent));
export { TooltipOverflowExample };
//# sourceMappingURL=Tooltip.Overflow.Example.js.map