| 1 |
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor'; |
| 2 |
import { applyFilters } from '@wordpress/hooks'; |
| 3 |
|
| 4 |
import IconPicker from '../../components/icon-picker'; |
| 5 |
import metadata from './block.json'; |
| 6 |
const { name } = metadata; |
| 7 |
|
| 8 |
/** |
| 9 |
* Block Save Class. |
| 10 |
* |
| 11 |
* @param props |
| 12 |
*/ |
| 13 |
export default function BlockSave(props) { |
| 14 |
const { icon, hideButton } = props.attributes; |
| 15 |
|
| 16 |
let className = 'ghostkit-alert'; |
| 17 |
|
| 18 |
className = applyFilters('ghostkit.blocks.className', className, { |
| 19 |
name, |
| 20 |
...props, |
| 21 |
}); |
| 22 |
|
| 23 |
const blockProps = useBlockProps.save({ className }); |
| 24 |
const innerBlockProps = useInnerBlocksProps.save({ |
| 25 |
className: 'ghostkit-alert-content', |
| 26 |
}); |
| 27 |
|
| 28 |
return ( |
| 29 |
<div {...blockProps}> |
| 30 |
{icon ? ( |
| 31 |
<IconPicker.Render |
| 32 |
name={icon} |
| 33 |
tag="div" |
| 34 |
className="ghostkit-alert-icon" |
| 35 |
/> |
| 36 |
) : null} |
| 37 |
<div {...innerBlockProps} /> |
| 38 |
{hideButton ? ( |
| 39 |
<div className="ghostkit-alert-hide-button"> |
| 40 |
<svg |
| 41 |
className="ghostkit-svg-icon" |
| 42 |
width="24" |
| 43 |
height="24" |
| 44 |
viewBox="0 0 24 24" |
| 45 |
fill="none" |
| 46 |
xmlns="http://www.w3.org/2000/svg" |
| 47 |
> |
| 48 |
<path |
| 49 |
d="M6.21967 6.21967C6.51256 5.92678 6.98744 5.92678 7.28033 6.21967L12 10.9393L16.7197 6.21967C17.0126 5.92678 17.4874 5.92678 17.7803 6.21967C18.0732 6.51256 18.0732 6.98744 17.7803 7.28033L13.0607 12L17.7803 16.7197C18.0732 17.0126 18.0732 17.4874 17.7803 17.7803C17.4874 18.0732 17.0126 18.0732 16.7197 17.7803L12 13.0607L7.28033 17.7803C6.98744 18.0732 6.51256 18.0732 6.21967 17.7803C5.92678 17.4874 5.92678 17.0126 6.21967 16.7197L10.9393 12L6.21967 7.28033C5.92678 6.98744 5.92678 6.51256 6.21967 6.21967Z" |
| 50 |
fill="currentColor" |
| 51 |
/> |
| 52 |
</svg> |
| 53 |
</div> |
| 54 |
) : null} |
| 55 |
</div> |
| 56 |
); |
| 57 |
} |
| 58 |
|