@braineet/ui
Version:
Braineet design system
50 lines (49 loc) • 1.95 kB
JavaScript
var _excluded = ["background", "elevation", "alignX", "alignY"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React from 'react';
import { useTheme } from 'styled-components';
import Box from '../box';
/**
* The `Pane` component.
*/
import { jsx as _jsx } from "react/jsx-runtime";
var Pane = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
var background = _ref.background,
elevation = _ref.elevation,
alignX = _ref.alignX,
alignY = _ref.alignY,
restProps = _objectWithoutPropertiesLoose(_ref, _excluded);
var theme = useTheme();
var elevationStyle = theme.elevations[elevation];
var paneStyle = {};
if (alignX || alignY) {
paneStyle.display = 'flex';
if (alignX) {
if (alignX === 'start' || alignX === 'end') {
paneStyle.justifyContent = "flex-" + alignX;
} else {
paneStyle.justifyContent = alignX;
}
}
if (alignY) {
if (alignY === 'start' || alignY === 'end') {
paneStyle.alignItems = "flex-" + alignY;
} else {
paneStyle.alignItems = alignY;
}
}
}
return /*#__PURE__*/_jsx(Box, _extends({
ref: ref,
background: background,
boxShadow: elevationStyle
}, paneStyle, restProps));
});
Pane.defaultProps = {
background: '',
elevation: 1,
alignX: null,
alignY: null
};
export default Pane;