UNPKG

zent

Version:

一套前端设计语言和基于React的实现

42 lines (41 loc) 2.23 kB
import { __assign, __extends, __rest } from "tslib"; import { jsx as _jsx } from "react/jsx-runtime"; import { Component } from 'react'; import cx from 'classnames'; import ConfigContext from './ConfigContext'; import LayoutBreakpointContext from './BreakPointContext'; import { getValueForBreakpoint } from './screen-breakpoints'; var LayoutCol = (function (_super) { __extends(LayoutCol, _super); function LayoutCol() { return _super !== null && _super.apply(this, arguments) || this; } LayoutCol.prototype.render = function () { var _this = this; return (_jsx(LayoutBreakpointContext.Consumer, { children: function (breakpoints) { return (_jsx(ConfigContext.Consumer, { children: function (config) { var _a; var _b = _this.props, span = _b.span, offset = _b.offset, order = _b.order, className = _b.className, style = _b.style, others = __rest(_b, ["span", "offset", "order", "className", "style"]); var colStyles = style; var colGutter = getValueForBreakpoint(breakpoints, config.colGutter); if (colGutter > 0) { var width = colGutter / 2; colStyles = __assign(__assign({}, colStyles), { paddingLeft: width, paddingRight: width }); } var spanValue = getValueForBreakpoint(breakpoints, span); var offsetValue = getValueForBreakpoint(breakpoints, offset); var orderValue = getValueForBreakpoint(breakpoints, order); var classes = cx('zent-col', (_a = {}, _a["zent-col-offset-" + offset] = offsetValue, _a["zent-col-order-" + order] = orderValue, _a), "zent-col-" + spanValue, className); return (_jsx("div", __assign({}, others, { className: classes, style: colStyles, "data-zv": '10.0.17' }, { children: _this.props.children }), void 0)); } }, void 0)); } }, void 0)); }; LayoutCol.defaultProps = { offset: 0, order: 0, }; return LayoutCol; }(Component)); export { LayoutCol }; export default LayoutCol;