UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

53 lines 3.05 kB
define(["require", "exports", "tslib", "react", "../../Utilities", "../../Icon", "./Persona.types", "./Persona.scss"], function (require, exports, tslib_1, React, Utilities_1, Icon_1, Persona_types_1, stylesImport) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var styles = stylesImport; var coinSizeFontScaleFactor = 6; var coinSizePresenceScaleFactor = 3; var presenceMaxSize = 40; var presenceFontMaxSize = 20; var PersonaPresence = /** @class */ (function (_super) { tslib_1.__extends(PersonaPresence, _super); function PersonaPresence(props) { return _super.call(this, props) || this; } PersonaPresence.prototype.render = function () { var _a = this.props, presence = _a.presence, coinSize = _a.coinSize; var presenceHeightWidth = coinSize && (coinSize / coinSizePresenceScaleFactor < presenceMaxSize ? coinSize / coinSizePresenceScaleFactor : presenceMaxSize); var presenceFontSize = coinSize && (coinSize / coinSizeFontScaleFactor < presenceFontMaxSize ? coinSize / coinSizeFontScaleFactor : presenceFontMaxSize); var coinSizeWithPresenceIconStyle = coinSize ? { fontSize: presenceFontSize, lineHeight: presenceHeightWidth + 'px' } : undefined; var coinSizeWithPresenceStyle = coinSize ? { width: presenceHeightWidth, height: presenceHeightWidth } : undefined; if (presence === Persona_types_1.PersonaPresence.none) { return null; } return (React.createElement("div", { className: Utilities_1.css('ms-Persona-presence', styles.presence), style: coinSizeWithPresenceStyle }, React.createElement(Icon_1.Icon, { className: Utilities_1.css('ms-Persona-presenceIcon', styles.presenceIcon), iconName: this._determineIcon(), style: coinSizeWithPresenceIconStyle }))); }; PersonaPresence.prototype._determineIcon = function () { var presence = this.props.presence; if (presence !== Persona_types_1.PersonaPresence.none) { var userPresence = Persona_types_1.PersonaPresence[presence]; switch (userPresence) { case 'online': userPresence = 'SkypeCheck'; break; case 'away': userPresence = 'SkypeClock'; break; case 'dnd': userPresence = 'SkypeMinus'; break; default: userPresence = ''; } return userPresence; } }; tslib_1.__decorate([ Utilities_1.autobind ], PersonaPresence.prototype, "_determineIcon", null); return PersonaPresence; }(React.Component)); exports.PersonaPresence = PersonaPresence; }); //# sourceMappingURL=PersonaPresence.js.map