deprecated
2 weeks ago
block.json
1 month ago
edit.js
2 months ago
icon-info.svg
2 months ago
icon-success.svg
2 months ago
icon-warning.svg
2 months ago
icon.svg
2 months ago
index.js
2 months ago
index.php
2 months ago
save.js
2 months ago
style.scss
2 months ago
variations.js
2 months ago
save.js
36 lines
| 1 | import { InnerBlocks, useBlockProps, RichText } from '@wordpress/block-editor'; |
| 2 | import parse from 'html-react-parser'; |
| 3 | import { fixBrokenUnicode } from '@vkblocks/utils/fixBrokenUnicode'; |
| 4 | |
| 5 | export default function save({ attributes }) { |
| 6 | const { style, icon: rawIcon, iconText, mobileIconPosition } = attributes; |
| 7 | const icon = rawIcon ? fixBrokenUnicode(rawIcon) : rawIcon; |
| 8 | |
| 9 | const blockProps = useBlockProps.save({ |
| 10 | className: `vk_alert alert alert-${style} ${icon ? 'has-alert-icon' : ''} ${ |
| 11 | mobileIconPosition === 'top' ? 'mobile-icon-top' : '' |
| 12 | }`, |
| 13 | }); |
| 14 | |
| 15 | let alertIcon = ''; |
| 16 | if (icon !== '' && icon !== undefined) { |
| 17 | alertIcon = ( |
| 18 | <div className="vk_alert_icon"> |
| 19 | <div className="vk_alert_icon_icon">{parse(icon)}</div> |
| 20 | <div className="vk_alert_icon_text"> |
| 21 | <RichText.Content tagName="span" value={iconText} /> |
| 22 | </div> |
| 23 | </div> |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | return ( |
| 28 | <div {...blockProps}> |
| 29 | {alertIcon} |
| 30 | <div className="vk_alert_content"> |
| 31 | <InnerBlocks.Content /> |
| 32 | </div> |
| 33 | </div> |
| 34 | ); |
| 35 | } |
| 36 |