d2-ui
Version:
49 lines (40 loc) • 1.66 kB
JavaScript
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import React from 'react';
import PropTypes from 'prop-types';
import { isArray } from 'lodash/fp';
import log from 'loglevel';
function SinglePanel(props) {
var children = props.children,
mainStyle = props.mainStyle,
otherProps = _objectWithoutProperties(props, ['children', 'mainStyle']);
var mergedMainStyle = _extends({
flex: 1,
display: 'flex',
flexOrientation: 'row',
marginTop: '8rem',
marginLeft: '2rem',
marginRight: '2rem'
}, mainStyle);
var childToRender = void 0;
if (isArray(children) && children.length) {
childToRender = children[0];
log.warn('You passed multiple children to the <SinglePanel /> component, this is not supported');
} else {
childToRender = children;
}
return React.createElement(
'main',
_extends({ style: mergedMainStyle }, otherProps),
childToRender
);
}
SinglePanel.propTypes = {
children: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
mainStyle: PropTypes.object
};
SinglePanel.defaultProps = {
mainStyle: {},
children: null
};
export default SinglePanel;