react-sleek
Version:
React Sleek Component Library
73 lines (72 loc) • 2.82 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var typestyle_1 = require("typestyle");
var Config_1 = require("../Config");
var Spacings_1 = require("../Style/Spacings");
var Radiuses_1 = require("../Style/Radiuses");
var Theme_1 = require("../Style/Theme");
var csx_1 = require("csx");
var Head2_1 = require("./Headings/Head2");
var ESectionAlign;
(function (ESectionAlign) {
ESectionAlign[ESectionAlign["Left"] = 0] = "Left";
ESectionAlign[ESectionAlign["Center"] = 1] = "Center";
ESectionAlign[ESectionAlign["Right"] = 2] = "Right";
})(ESectionAlign = exports.ESectionAlign || (exports.ESectionAlign = {}));
var Section = /** @class */ (function (_super) {
__extends(Section, _super);
function Section() {
return _super !== null && _super.apply(this, arguments) || this;
}
Section.prototype.render = function () {
var theme = Theme_1.default(Config_1.default.getTheme());
var styleProps = {
backgroundColor: theme.ContentBackground,
color: theme.Text,
textAlign: this.props.align === ESectionAlign.Right
? 'right'
: this.props.align === ESectionAlign.Center
? 'center'
: 'left',
};
if (this.props.fill) {
styleProps.flex = 1;
}
if (!this.props.last) {
styleProps.marginBottom = csx_1.px(Spacings_1.default.Compact);
}
var themeStyle = typestyle_1.style(styleProps);
return (React.createElement("div", { className: typestyle_1.classes(styles.sectionBase, themeStyle) },
React.createElement(Head2_1.default, null, this.props.title),
React.createElement("div", null, this.props.children)));
};
Section.defaultProps = {
fill: false,
last: false,
align: ESectionAlign.Left,
};
return Section;
}(React.PureComponent));
exports.default = Section;
var styles = {
sectionBase: typestyle_1.style({
display: 'flex',
flexDirection: 'column',
borderRadius: Radiuses_1.default.Large,
padding: csx_1.px(Spacings_1.default.Default),
}),
};