| 1 |
import classnames from 'classnames/dedupe'; |
| 2 |
|
| 3 |
import { |
| 4 |
RichText, |
| 5 |
useBlockProps, |
| 6 |
useInnerBlocksProps, |
| 7 |
} from '@wordpress/block-editor'; |
| 8 |
import { applyFilters } from '@wordpress/hooks'; |
| 9 |
|
| 10 |
import metadata from './block.json'; |
| 11 |
|
| 12 |
const { name } = metadata; |
| 13 |
|
| 14 |
/** |
| 15 |
* Block Save Class. |
| 16 |
* |
| 17 |
* @param props |
| 18 |
*/ |
| 19 |
export default function BlockSave(props) { |
| 20 |
const { |
| 21 |
popularText, |
| 22 |
title, |
| 23 |
price, |
| 24 |
description, |
| 25 |
priceCurrency, |
| 26 |
priceRepeat, |
| 27 |
features, |
| 28 |
|
| 29 |
showPopular, |
| 30 |
showTitle, |
| 31 |
showPrice, |
| 32 |
showPriceCurrency, |
| 33 |
showPriceRepeat, |
| 34 |
showDescription, |
| 35 |
showFeatures, |
| 36 |
showButton, |
| 37 |
} = props.attributes; |
| 38 |
|
| 39 |
let className = classnames( |
| 40 |
'ghostkit-pricing-table-item', |
| 41 |
showPopular && 'ghostkit-pricing-table-item-popular' |
| 42 |
); |
| 43 |
|
| 44 |
className = applyFilters('ghostkit.blocks.className', className, { |
| 45 |
name, |
| 46 |
...props, |
| 47 |
}); |
| 48 |
|
| 49 |
const blockProps = useBlockProps.save({ |
| 50 |
className: 'ghostkit-pricing-table-item-wrap', |
| 51 |
}); |
| 52 |
const innerBlocksProps = useInnerBlocksProps.save({ |
| 53 |
className: 'ghostkit-pricing-table-item-button-wrapper', |
| 54 |
}); |
| 55 |
|
| 56 |
return ( |
| 57 |
<div {...blockProps}> |
| 58 |
<div className={className}> |
| 59 |
{showTitle && !RichText.isEmpty(title) ? ( |
| 60 |
<RichText.Content |
| 61 |
tagName="h3" |
| 62 |
className="ghostkit-pricing-table-item-title" |
| 63 |
value={title} |
| 64 |
/> |
| 65 |
) : null} |
| 66 |
|
| 67 |
{showPrice && !RichText.isEmpty(price) ? ( |
| 68 |
<div className="ghostkit-pricing-table-item-price"> |
| 69 |
{showPriceCurrency && |
| 70 |
!RichText.isEmpty(priceCurrency) ? ( |
| 71 |
<RichText.Content |
| 72 |
tagName="span" |
| 73 |
className="ghostkit-pricing-table-item-price-currency" |
| 74 |
value={priceCurrency} |
| 75 |
/> |
| 76 |
) : null} |
| 77 |
<RichText.Content |
| 78 |
tagName="span" |
| 79 |
className="ghostkit-pricing-table-item-price-amount" |
| 80 |
value={price} |
| 81 |
/> |
| 82 |
{showPriceRepeat && !RichText.isEmpty(priceRepeat) ? ( |
| 83 |
<RichText.Content |
| 84 |
tagName="span" |
| 85 |
className="ghostkit-pricing-table-item-price-repeat" |
| 86 |
value={priceRepeat} |
| 87 |
/> |
| 88 |
) : null} |
| 89 |
</div> |
| 90 |
) : null} |
| 91 |
|
| 92 |
{showDescription && !RichText.isEmpty(description) ? ( |
| 93 |
<RichText.Content |
| 94 |
tagName="div" |
| 95 |
className="ghostkit-pricing-table-item-description" |
| 96 |
value={description} |
| 97 |
/> |
| 98 |
) : null} |
| 99 |
|
| 100 |
{showFeatures && !RichText.isEmpty(features) ? ( |
| 101 |
<RichText.Content |
| 102 |
tagName="ul" |
| 103 |
className="ghostkit-pricing-table-item-features" |
| 104 |
value={features} |
| 105 |
/> |
| 106 |
) : null} |
| 107 |
|
| 108 |
{showButton ? <div {...innerBlocksProps} /> : null} |
| 109 |
|
| 110 |
{showPopular && !RichText.isEmpty(popularText) ? ( |
| 111 |
<RichText.Content |
| 112 |
tagName="div" |
| 113 |
className="ghostkit-pricing-table-item-popular-badge" |
| 114 |
value={popularText} |
| 115 |
/> |
| 116 |
) : null} |
| 117 |
</div> |
| 118 |
</div> |
| 119 |
); |
| 120 |
} |
| 121 |
|