2022-05-19 16:16:46 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2024-05-31 03:49:36 +00:00
|
|
|
import clsx from 'clsx';
|
2022-05-19 16:16:46 +00:00
|
|
|
import { RichText, InnerBlocks } from '@wordpress/block-editor';
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
|
2022-05-30 14:38:52 +00:00
|
|
|
interface CallToActionProps {
|
|
|
|
itemId: number | 'preview';
|
|
|
|
linkText: string;
|
|
|
|
permalink: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const CallToAction = ( {
|
|
|
|
itemId,
|
|
|
|
linkText,
|
|
|
|
permalink,
|
|
|
|
}: CallToActionProps ) => {
|
2024-05-31 03:49:36 +00:00
|
|
|
const buttonClasses = clsx( 'wp-block-button__link', 'is-style-fill' );
|
2022-05-19 16:16:46 +00:00
|
|
|
const buttonStyle = {
|
|
|
|
backgroundColor: 'vivid-green-cyan',
|
|
|
|
borderRadius: '5px',
|
|
|
|
};
|
|
|
|
const wrapperStyle = {
|
|
|
|
width: '100%',
|
|
|
|
};
|
|
|
|
return itemId === 'preview' ? (
|
|
|
|
<div className="wp-block-button aligncenter" style={ wrapperStyle }>
|
|
|
|
<RichText.Content
|
|
|
|
tagName="a"
|
|
|
|
className={ buttonClasses }
|
|
|
|
href={ permalink }
|
|
|
|
title={ linkText }
|
|
|
|
style={ buttonStyle }
|
|
|
|
value={ linkText }
|
|
|
|
target={ permalink }
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<InnerBlocks
|
|
|
|
template={ [
|
|
|
|
[
|
|
|
|
'core/buttons',
|
|
|
|
{
|
|
|
|
layout: { type: 'flex', justifyContent: 'center' },
|
|
|
|
},
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'core/button',
|
|
|
|
{
|
2023-12-12 23:05:20 +00:00
|
|
|
text: __( 'Shop now', 'woocommerce' ),
|
2022-05-19 16:16:46 +00:00
|
|
|
url: permalink,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
] }
|
|
|
|
templateLock="all"
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|