UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

62 lines 2.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var React = require("react"); var HoverCard_1 = require("office-ui-fabric-react/lib/HoverCard"); var Fabric_1 = require("office-ui-fabric-react/lib/Fabric"); var Button_1 = require("office-ui-fabric-react/lib/Button"); var Styling_1 = require("office-ui-fabric-react/lib/Styling"); var classNames = Styling_1.mergeStyleSets({ plainCard: { width: 200, height: 200, display: 'flex', alignItems: 'center', justifyContent: 'center' }, target: { fontWeight: '600', display: 'inline-block', border: '1px dashed #605e5c', padding: 5, borderRadius: 2 } }); var HoverCardInstantDismissExample = /** @class */ (function (_super) { tslib_1.__extends(HoverCardInstantDismissExample, _super); function HoverCardInstantDismissExample() { var _this = _super !== null && _super.apply(this, arguments) || this; _this._hoverCard = React.createRef(); _this._onRenderPlainCard = function () { return (React.createElement("div", { className: classNames.plainCard }, React.createElement(Button_1.DefaultButton, { onClick: _this._instantDismissCard, text: "Instant Dismiss" }))); }; _this._instantDismissCard = function () { if (_this._hoverCard.current) { _this._hoverCard.current.dismiss(); } }; _this._onCardHide = function () { console.log('I am now hidden'); }; return _this; } HoverCardInstantDismissExample.prototype.render = function () { var plainCardProps = { onRenderPlainCard: this._onRenderPlainCard }; return (React.createElement(Fabric_1.Fabric, null, React.createElement("p", null, "In cases where an instant dismiss of the card is needed, public method ", React.createElement("i", null, "dismiss()"), " can be used through its", ' ', React.createElement("i", null, "componentRef"), " prop."), React.createElement(HoverCard_1.HoverCard, { cardDismissDelay: 2000, type: HoverCard_1.HoverCardType.plain, plainCardProps: plainCardProps, componentRef: this._hoverCard, onCardHide: this._onCardHide }, React.createElement("span", { className: classNames.target }, "Hover Over Me")))); }; return HoverCardInstantDismissExample; }(React.Component)); exports.HoverCardInstantDismissExample = HoverCardInstantDismissExample; //# sourceMappingURL=HoverCard.InstantDismiss.Example.js.map