armstrong-react
Version:
Rocketmakers Armstrong library of React components
45 lines (44 loc) • 1.84 kB
JavaScript
;
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 __());
};
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
var React = require("react");
var classBuilder_1 = require("./../../utilities/classBuilder");
var Heading = (function (_super) {
__extends(Heading, _super);
function Heading() {
_super.apply(this, arguments);
}
Heading.prototype.render = function () {
var classes = classBuilder_1.classNames(classBuilder_1.cd(this.props.styleType, this.props.styleType !== this.props.elementType), this.props.className);
if (!classes) {
classes = null;
}
switch (this.props.elementType) {
case "h1":
return React.createElement("h1", __assign({}, this.props, {className: classes}), this.props.children);
case "h2":
return React.createElement("h2", __assign({}, this.props, {className: classes}), this.props.children);
case "h3":
return React.createElement("h3", __assign({}, this.props, {className: classes}), this.props.children);
case "div":
return React.createElement("div", __assign({}, this.props, {className: classes}), this.props.children);
}
};
Heading.defaultProps = {
elementType: "h3",
styleType: "heading3"
};
return Heading;
}(React.Component));
exports.Heading = Heading;