UNPKG

@nodeject/ui-components

Version:

UI library for non-trivial components

35 lines (34 loc) 1.72 kB
import cc from 'classcat'; import * as React from 'react'; import { displayNames } from '../types'; import * as styles from './Content.module.less'; export var Content = function (props) { var _a; var _b, _c, _d; var children = (_c = (_b = props.children) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.children; var childrenTypes; if (Array.isArray(children)) { childrenTypes = React.Children.map(children, function (child) { var _a; return { displayName: (_a = child === null || child === void 0 ? void 0 : child.type) === null || _a === void 0 ? void 0 : _a.displayName, fixed: child === null || child === void 0 ? void 0 : child.props.fixed, side: child === null || child === void 0 ? void 0 : child.props.side }; }); } var isHeaderFixed = (_d = childrenTypes === null || childrenTypes === void 0 ? void 0 : childrenTypes.find(function (c) { return c.displayName === displayNames.header; })) === null || _d === void 0 ? void 0 : _d.fixed; return (React.createElement("section", { className: cc((_a = { schedioLayoutContent: true }, _a[styles.schedioLayoutContent] = true, _a[styles.fixedHeader] = isHeaderFixed, _a[props.className] = props.className, _a[styles.fixedContentHeight] = props.fixedHeight, _a)), style: props.style }, React.createElement("div", { className: styles.contentWrapper }, props.children))); }; Content.defaultProps = { fixedHeight: false }; Content.displayName = 'SchedioLayoutContent';