@shopgate/pwa-common
Version:
Common library for the Shopgate Connect PWA.
40 lines (39 loc) • 1.37 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import Portal from "../Portal";
import { AFTER, BEFORE } from "../../constants/Portals";
/**
* The SurroundPortals component renders three Portal component. The main portal is wrapped around
* its children, the two additional portals are rendered before and after the main portal.
* The names of the additional portals are automatically created from the name of the main portal
* with a ".before" and ".after" suffix.
*
* @param {Object} props The component props
* @param {string} props.portalName Name for the main portal
* @param {Object} props.portalProps Props that are assigned to the portals
* @param {React.ReactNode} props.children Component children
* @returns {JSX.Element}
*/
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
const SurroundPortals = ({
portalName,
portalProps,
children
}) => /*#__PURE__*/_jsxs(_Fragment, {
children: [/*#__PURE__*/_jsx(Portal, {
name: `${portalName}.${BEFORE}`,
props: portalProps
}), /*#__PURE__*/_jsx(Portal, {
name: portalName,
props: portalProps,
children: children
}), /*#__PURE__*/_jsx(Portal, {
name: `${portalName}.${AFTER}`,
props: portalProps
})]
});
SurroundPortals.defaultProps = {
children: null,
portalProps: null
};
export default SurroundPortals;