UNPKG

2.59 kBJavaScriptView Raw
1import { __extends } from "tslib";
2import * as React from 'react';
3import { classNamesFunction, initializeComponentRef } from '../../Utilities';
4import { PersonaSize } from '../../Persona';
5import { PersonaCoin } from '../../PersonaCoin';
6var getClassNames = classNamesFunction();
7/**
8 * {@docCategory DocumentCard}
9 */
10var DocumentCardActivityBase = /** @class */ (function (_super) {
11 __extends(DocumentCardActivityBase, _super);
12 function DocumentCardActivityBase(props) {
13 var _this = _super.call(this, props) || this;
14 initializeComponentRef(_this);
15 return _this;
16 }
17 DocumentCardActivityBase.prototype.render = function () {
18 var _a = this.props, activity = _a.activity, people = _a.people, styles = _a.styles, theme = _a.theme, className = _a.className;
19 this._classNames = getClassNames(styles, {
20 theme: theme,
21 className: className,
22 multiplePeople: people.length > 1,
23 });
24 if (!people || people.length === 0) {
25 return null;
26 }
27 return (React.createElement("div", { className: this._classNames.root },
28 this._renderAvatars(people),
29 React.createElement("div", { className: this._classNames.details },
30 React.createElement("span", { className: this._classNames.name }, this._getNameString(people)),
31 React.createElement("span", { className: this._classNames.activity }, activity))));
32 };
33 DocumentCardActivityBase.prototype._renderAvatars = function (people) {
34 return (React.createElement("div", { className: this._classNames.avatars },
35 people.length > 1 ? this._renderAvatar(people[1]) : null,
36 this._renderAvatar(people[0])));
37 };
38 DocumentCardActivityBase.prototype._renderAvatar = function (person) {
39 return (React.createElement("div", { className: this._classNames.avatar },
40 React.createElement(PersonaCoin, { imageInitials: person.initials, text: person.name, imageUrl: person.profileImageSrc, initialsColor: person.initialsColor, allowPhoneInitials: person.allowPhoneInitials, role: "presentation", size: PersonaSize.size32 })));
41 };
42 DocumentCardActivityBase.prototype._getNameString = function (people) {
43 var nameString = people[0].name;
44 if (people.length >= 2) {
45 nameString += ' +' + (people.length - 1);
46 }
47 return nameString;
48 };
49 return DocumentCardActivityBase;
50}(React.Component));
51export { DocumentCardActivityBase };
52//# sourceMappingURL=DocumentCardActivity.base.js.map
\No newline at end of file