UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

40 lines (39 loc) 2.02 kB
var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; define(["require", "exports", 'react', './DocumentCard.Props', '../../utilities/css', './DocumentCard.scss'], function (require, exports, React, DocumentCard_Props_1, css_1) { "use strict"; var DocumentCard = (function (_super) { __extends(DocumentCard, _super); function DocumentCard() { _super.apply(this, arguments); } DocumentCard.prototype.render = function () { var _a = this.props, onClick = _a.onClick, onClickHref = _a.onClickHref, children = _a.children, className = _a.className, type = _a.type, accentColor = _a.accentColor; // If no onClickFunction was provided and we do have an onClickURL, create a function from it. if (!onClick && onClickHref) { onClick = function () { window.location.href = onClickHref; }; } // Override the border color if an accent color was provided (compact card only) var style; if (type === DocumentCard_Props_1.DocumentCardType.compact && accentColor) { style = { borderBottomColor: accentColor }; } return (React.createElement("div", {className: css_1.css('ms-DocumentCard', { 'ms-DocumentCard--actionable': onClick ? true : false, 'ms-DocumentCard--compact': type === DocumentCard_Props_1.DocumentCardType.compact ? true : false }, className), onClick: onClick, style: style}, children)); }; DocumentCard.defaultProps = { type: DocumentCard_Props_1.DocumentCardType.normal }; return DocumentCard; }(React.Component)); exports.DocumentCard = DocumentCard; });