UNPKG

@braineet/ui

Version:

Braineet design system

50 lines (49 loc) 1.77 kB
var _excluded = ["background", "elevation", "alignX", "alignY"]; function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } 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;