2025-01-21 18:57:36 +01:00
|
|
|
import classNames from 'classnames';
|
|
|
|
|
2025-01-22 16:47:20 +01:00
|
|
|
const Description = ( { children, className = '' } ) => {
|
2025-01-21 18:57:36 +01:00
|
|
|
// Don't output anything if description is empty.
|
|
|
|
if ( ! children ) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2025-01-22 17:19:23 +01:00
|
|
|
const elementClasses = classNames( 'ppcp--description', className );
|
2025-01-21 18:57:36 +01:00
|
|
|
|
2025-01-22 16:47:20 +01:00
|
|
|
if ( 'string' !== typeof children ) {
|
2025-01-21 18:57:36 +01:00
|
|
|
return <span className={ elementClasses }>{ children }</span>;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<span
|
|
|
|
className={ elementClasses }
|
|
|
|
dangerouslySetInnerHTML={ { __html: children } }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Description;
|