import classnames from 'classnames/dedupe';
import { RichText, useBlockProps } from '@wordpress/block-editor';
import { applyFilters } from '@wordpress/hooks';
import IconPicker from '../../components/icon-picker';
import metadata from './block.json';
const { name } = metadata;
/**
* Block Save Class.
*
* @param props
*/
export default function BlockSave(props) {
const {
tagName,
text,
icon,
iconPosition,
hideText,
url,
ariaLabel,
target,
rel,
size,
focusOutlineWeight,
focusOutlineColor,
} = props.attributes;
let className = classnames(
'ghostkit-button',
size && `ghostkit-button-${size}`,
hideText && 'ghostkit-button-icon-only'
);
// focus outline
if (focusOutlineWeight && focusOutlineColor) {
className = classnames(className, 'ghostkit-button-with-outline');
}
className = applyFilters('ghostkit.blocks.className', className, {
name,
...props,
});
const result = [];
if (!hideText) {
result.push(
);
}
// add icon.
if (icon) {
result.unshift(
);
}
const Tag = tagName || (url ? 'a' : 'span');
const blockProps = useBlockProps.save({
className,
...(Tag === 'a'
? {
href: url,
target: target || null,
rel: rel || null,
'aria-label': ariaLabel || null,
}
: {}),
});
return {result};
}