@uifabric/experiments
Version:
Experimental React components for building experiences for Office 365.
37 lines • 1.77 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { BaseComponent } from '../../Utilities';
import { ChicletCard } from './ChicletCard';
import { getOpenGraphProperties } from './OpenGraph';
import { ChicletSize } from './Chiclet.types';
var ChicletBase = /** @class */ (function (_super) {
tslib_1.__extends(ChicletBase, _super);
function ChicletBase(props) {
var _this = _super.call(this, props) || this;
var chicletCardProps = getOpenGraphProperties(_this.props.url);
_this.state = { chicletCardProps: chicletCardProps };
return _this;
}
ChicletBase.prototype.render = function () {
var _a = this.props, size = _a.size, footer = _a.footer, description = _a.description;
var chicletCardProps = this.state.chicletCardProps;
switch (size) {
case ChicletSize.medium:
return React.createElement(ChicletCard, tslib_1.__assign({}, chicletCardProps, { onClick: this._onClick, footer: footer, description: description }));
// @todo: handle other types of chiclets
default:
return React.createElement(ChicletCard, tslib_1.__assign({}, chicletCardProps, { onClick: this._onClick, footer: footer, description: description }));
}
};
ChicletBase.prototype.componentWillReceiveProps = function (nextProps) {
if (this.props.url !== nextProps.url) {
this.setState({ chicletCardProps: getOpenGraphProperties(this.props.url) });
}
};
ChicletBase.prototype._onClick = function () {
// @todo: default click handler
};
return ChicletBase;
}(BaseComponent));
export { ChicletBase };
//# sourceMappingURL=Chiclet.base.js.map