deprecated
2 months ago
block.json
1 month ago
edit.js
2 months ago
icon.svg
2 months ago
index.js
2 months ago
index.php
2 months ago
mediaUpload.js
2 months ago
save.js
2 weeks ago
style.scss
2 months ago
utils.js
2 months ago
save.js
93 lines
| 1 | import { RichText, useBlockProps } from '@wordpress/block-editor'; |
| 2 | import { |
| 3 | getButtonClass, |
| 4 | getLinkClass, |
| 5 | getLinkStyle, |
| 6 | getFontawesomeIcon, |
| 7 | getContainerClass, |
| 8 | } from './utils'; |
| 9 | import { PrContentMediaUpload } from './mediaUpload'; |
| 10 | import { fixBrokenUnicode } from '@vkblocks/utils/fixBrokenUnicode'; |
| 11 | import parse from 'html-react-parser'; |
| 12 | |
| 13 | export default function save({ attributes }) { |
| 14 | const { |
| 15 | title, |
| 16 | titleColor, |
| 17 | content, |
| 18 | contentColor, |
| 19 | url, |
| 20 | buttonType, |
| 21 | buttonColor, |
| 22 | buttonColorCustom, |
| 23 | buttonText, |
| 24 | buttonTarget, |
| 25 | Image, |
| 26 | ImageBorderColor, |
| 27 | layout, |
| 28 | fontAwesomeIconBefore: fontAwesomeIconBeforeRaw, |
| 29 | fontAwesomeIconAfter: fontAwesomeIconAfterRaw, |
| 30 | } = attributes; |
| 31 | |
| 32 | const fontAwesomeIconBefore = fixBrokenUnicode(fontAwesomeIconBeforeRaw); |
| 33 | const fontAwesomeIconAfter = fixBrokenUnicode(fontAwesomeIconAfterRaw); |
| 34 | |
| 35 | const containerClass = getContainerClass(layout); |
| 36 | const btnClass = getButtonClass(buttonColorCustom); |
| 37 | const linkClass = getLinkClass(buttonColor, buttonColorCustom, buttonType); |
| 38 | const linkStyle = getLinkStyle(buttonColorCustom, buttonType); |
| 39 | const iconBefore = getFontawesomeIcon( |
| 40 | fontAwesomeIconBefore, |
| 41 | 'vk_button_link_before' |
| 42 | ); |
| 43 | const iconAfter = getFontawesomeIcon( |
| 44 | fontAwesomeIconAfter, |
| 45 | 'vk_button_link_after' |
| 46 | ); |
| 47 | |
| 48 | return ( |
| 49 | <div {...useBlockProps.save({ className: containerClass })}> |
| 50 | <div className="col-sm-6 vk_prContent_colImg"> |
| 51 | <PrContentMediaUpload |
| 52 | Image={Image} |
| 53 | ImageBorderColor={ImageBorderColor} |
| 54 | /> |
| 55 | </div> |
| 56 | <div className="col-sm-6 vk_prContent_colTxt"> |
| 57 | <RichText.Content |
| 58 | tagName="h3" |
| 59 | value={title} |
| 60 | className={'vk_prContent_colTxt_title'} |
| 61 | style={{ color: titleColor }} |
| 62 | /> |
| 63 | <RichText.Content |
| 64 | tagName="p" |
| 65 | className={'vk_prContent_colTxt_text'} |
| 66 | value={content} |
| 67 | style={{ color: contentColor }} |
| 68 | /> |
| 69 | {buttonText && ( |
| 70 | /* eslint react/jsx-no-target-blank: 0 */ |
| 71 | <div className={btnClass}> |
| 72 | <a |
| 73 | href={url} |
| 74 | className={linkClass} |
| 75 | rel={ |
| 76 | buttonTarget ? 'noopener noreferrer' : undefined |
| 77 | } |
| 78 | style={linkStyle} |
| 79 | target={buttonTarget ? '_blank' : undefined} |
| 80 | > |
| 81 | {parse(iconBefore)} |
| 82 | <span className="vk_button_link_txt"> |
| 83 | {buttonText} |
| 84 | </span> |
| 85 | {parse(iconAfter)} |
| 86 | </a> |
| 87 | </div> |
| 88 | )} |
| 89 | </div> |
| 90 | </div> |
| 91 | ); |
| 92 | } |
| 93 |