import classnames from 'classnames/dedupe'; import { RichText, useBlockProps } from '@wordpress/block-editor'; /** * Block Save Class. * * @param props */ export default function BlockSave(props) { const { attributes } = props; const { direction, trigger, caption, showLabels, labelBeforeText, labelAfterText, labelAlign, beforeId, beforeUrl, beforeAlt, beforeWidth, beforeHeight, afterId, afterUrl, afterAlt, afterWidth, afterHeight, } = attributes; if (!beforeUrl || !afterUrl) { return null; } let { className } = attributes; className = classnames( 'ghostkit-image-compare', direction === 'vertical' ? 'ghostkit-image-compare-vertical' : false, trigger ? `ghostkit-image-compare-trigger-${trigger}` : false, showLabels && labelAlign ? `ghostkit-image-compare-labels-align-${labelAlign}` : false, className ); const blockProps = useBlockProps.save({ className }); return (
{beforeAlt} {showLabels && !RichText.isEmpty(labelBeforeText) ? ( ) : null}
{afterAlt} {showLabels && !RichText.isEmpty(labelAfterText) ? ( ) : null}
{!RichText.isEmpty(caption) ? ( ) : null}
); }