| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; |
| 3 |
import { faCircleInfo } from "@fortawesome/free-solid-svg-icons"; |
| 4 |
|
| 5 |
/** |
| 6 |
* Menu block control component. |
| 7 |
* |
| 8 |
* This control will be used for both enabling/disabling blocks and showing info about them. |
| 9 |
* |
| 10 |
* @class |
| 11 |
* |
| 12 |
* @param {Object} props component properties |
| 13 |
* @param {string} props.title block title |
| 14 |
* @param {string} props.name registry id of block |
| 15 |
* @param {HTMLElement} props.iconElement block icon element |
| 16 |
* @param {boolean} props.isPro block belongs to pro version |
| 17 |
* @param {boolean} props.isProPlugin plugin pro status |
| 18 |
* @param {Function} props.showUpsell set target block type for modal interface |
| 19 |
* @param {string | null} [props.demoUrl=null] demo url for block |
| 20 |
*/ |
| 21 |
function BlockControlCard({ |
| 22 |
title, |
| 23 |
name, |
| 24 |
iconElement, |
| 25 |
isPro, |
| 26 |
isProPlugin, |
| 27 |
showUpsell, |
| 28 |
demoUrl = null, |
| 29 |
}) { |
| 30 |
return ( |
| 31 |
<div |
| 32 |
className={"tableberg-block-control"} |
| 33 |
data-enabled={JSON.stringify(isProPlugin ? true : !isPro)} |
| 34 |
> |
| 35 |
<div className={"tableberg-block-title"}> |
| 36 |
<div |
| 37 |
className={"tableberg-block-title-left-container"} |
| 38 |
data-demo={demoUrl !== null} |
| 39 |
> |
| 40 |
<div className={"tableberg-title-icon"}>{iconElement}</div> |
| 41 |
<div className={"tableberg-title-text"}> |
| 42 |
{title} |
| 43 |
{isPro && ( |
| 44 |
<span |
| 45 |
className={ |
| 46 |
"tableberg-pro-block-card-title-suffix" |
| 47 |
} |
| 48 |
> |
| 49 |
PRO |
| 50 |
</span> |
| 51 |
)} |
| 52 |
</div> |
| 53 |
{demoUrl && ( |
| 54 |
<div className={"tableberg-title-demo"}> |
| 55 |
<a |
| 56 |
href={demoUrl} |
| 57 |
target={"_blank"} |
| 58 |
rel="noreferrer" |
| 59 |
className={"tableberg-strip-anchor-styles"} |
| 60 |
> |
| 61 |
{__("See Documentation", "tableberg")} |
| 62 |
</a> |
| 63 |
</div> |
| 64 |
)} |
| 65 |
</div> |
| 66 |
{isPro && !isProPlugin && ( |
| 67 |
<div className={"tableberg-block-title-right-container"}> |
| 68 |
<div |
| 69 |
role={"button"} |
| 70 |
className={"tableberg-pro-block-card-info-button"} |
| 71 |
onClick={e => { |
| 72 |
e.preventDefault(); |
| 73 |
showUpsell(name); |
| 74 |
}} |
| 75 |
> |
| 76 |
<FontAwesomeIcon icon={faCircleInfo} /> |
| 77 |
</div> |
| 78 |
</div> |
| 79 |
)} |
| 80 |
</div> |
| 81 |
</div> |
| 82 |
); |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* @module BlockControl |
| 87 |
*/ |
| 88 |
export default BlockControlCard; |
| 89 |
|