2021-07-02 14:56:39 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2022-04-01 13:45:18 +00:00
|
|
|
import classnames from 'classnames';
|
2023-03-02 14:26:00 +00:00
|
|
|
import { Children } from '@wordpress/element';
|
|
|
|
import type { ReactNode } from 'react';
|
2021-07-02 14:56:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './style.scss';
|
|
|
|
|
2023-11-20 12:53:41 +00:00
|
|
|
export interface TotalsWrapperProps {
|
2021-07-02 14:56:39 +00:00
|
|
|
children: ReactNode;
|
|
|
|
/* If this TotalsWrapper is being used to wrap a Slot */
|
|
|
|
slotWrapper?: boolean;
|
2022-04-01 13:45:18 +00:00
|
|
|
className?: string;
|
2021-07-02 14:56:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const TotalsWrapper = ( {
|
|
|
|
children,
|
|
|
|
slotWrapper = false,
|
2022-04-01 13:45:18 +00:00
|
|
|
className,
|
2021-07-02 14:56:39 +00:00
|
|
|
}: TotalsWrapperProps ): JSX.Element | null => {
|
|
|
|
return Children.count( children ) ? (
|
|
|
|
<div
|
2022-04-01 13:45:18 +00:00
|
|
|
className={ classnames(
|
|
|
|
className,
|
|
|
|
'wc-block-components-totals-wrapper',
|
|
|
|
{
|
|
|
|
'slot-wrapper': slotWrapper,
|
|
|
|
}
|
|
|
|
) }
|
2021-07-02 14:56:39 +00:00
|
|
|
>
|
|
|
|
{ children }
|
|
|
|
</div>
|
|
|
|
) : null;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default TotalsWrapper;
|