Move powered by mailpoet block back to the main mailpoet assets folder

MAILPOET-6215
This commit is contained in:
Oluwaseun Olorunsola
2024-11-08 18:01:20 +01:00
committed by Oluwaseun Olorunsola
parent 716ba4ebc3
commit e6d607028c
9 changed files with 141 additions and 150 deletions

View File

@ -1,25 +0,0 @@
{
"name": "mailpoet/powered-by-mailpoet",
"version": "1.0.0",
"title": "Powered By MailPoet",
"description": "A MailPoet logo will appear in the footer of all emails sent with the free version of MailPoet.",
"category": "mailpoet",
"keywords": [ "MailPoet" ],
"textdomain": "mailpoet",
"supports": {
"align": false,
"html": false,
"multiple": false,
"reusable": false,
"inserter": false,
"lock": false
},
"apiVersion": 2,
"$schema": "https://schemas.wp.org/trunk/block.json",
"attributes": {
"logo": {
"type": "string",
"default": "default"
}
}
}

View File

@ -1,107 +0,0 @@
import { registerBlockType } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
import { PanelBody, RadioControl, Icon } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import metadata from './block.json';
import { storeName } from '../../engine/store';
import MailPoetIcon from './mailpoet-icon';
function LogoImage( {
logoSrc,
style = {},
}: {
logoSrc: string;
style?: React.CSSProperties;
} ): JSX.Element {
return (
<img
src={ logoSrc }
style={ style }
alt="Powered by MailPoet"
width="100px"
/>
);
}
function Edit( {
attributes,
setAttributes,
}: {
attributes: { logo: string };
setAttributes: ( value: { logo: string } ) => void;
} ): JSX.Element {
const blockProps = useBlockProps();
const { cdnUrl, isPremiumPluginActive } = useSelect(
( select ) => ( {
cdnUrl: select( storeName ).getCdnUrl(),
isPremiumPluginActive: select( storeName ).isPremiumPluginActive(),
} ),
[]
);
if ( isPremiumPluginActive ) {
return null;
}
const selectedLogo = attributes?.logo ?? 'default';
return (
<div { ...blockProps }>
<div
className="mailpoet-email-footer-credit"
style={ { textAlign: 'center' } }
>
<LogoImage
logoSrc={ `${ cdnUrl }email-editor/logo-${ selectedLogo }.png` }
/>
</div>
<InspectorControls>
<PanelBody title={ __( 'Settings', 'mailpoet' ) }>
<RadioControl
className="wc-block-editor-mini-cart__cart-icon-toggle"
label={ __( 'Image', 'mailpoet' ) }
selected={ selectedLogo }
options={ [
{
label: (
<LogoImage
logoSrc={ `${ cdnUrl }email-editor/logo-default.png` }
/>
) as unknown as string,
value: 'default',
},
{
label: (
<LogoImage
logoSrc={ `${ cdnUrl }email-editor/logo-light.png` }
/>
) as unknown as string,
value: 'light',
},
{
label: (
<LogoImage
logoSrc={ `${ cdnUrl }email-editor/logo-dark.png` }
style={ { background: '#000000' } }
/>
) as unknown as string,
value: 'dark',
},
] }
onChange={ ( value ) => {
setAttributes( {
logo: value,
} );
} }
/>
</PanelBody>
</InspectorControls>
</div>
);
}
// @ts-expect-error TS2322 Different types
registerBlockType( metadata, {
icon: {
src: <Icon icon={ MailPoetIcon } />,
},
edit: Edit,
} );

View File

@ -1,16 +0,0 @@
import { SVG } from '@wordpress/components';
function MailPoetIcon(): JSX.Element {
return (
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 152.02 156.4">
<g data-name="Layer 2">
<path
d="M37.71 89.1c3.5 0 5.9-.8 7.2-2.3a8 8 0 0 0 2-5.4V35.7l17 45.1a12.68 12.68 0 0 0 3.7 5.4c1.6 1.3 4 2 7.2 2a12.54 12.54 0 0 0 5.9-1.4 8.41 8.41 0 0 0 3.9-5l18.1-50V81a8.53 8.53 0 0 0 2.1 6.1c1.4 1.4 3.7 2.2 6.9 2.2 3.5 0 5.9-.8 7.2-2.3a8 8 0 0 0 2-5.4V8.7a7.48 7.48 0 0 0-3.3-6.6c-2.1-1.4-5-2.1-8.6-2.1a19.3 19.3 0 0 0-9.4 2 11.63 11.63 0 0 0-5.1 6.8l-19.6 58.3-20.5-58.7a12.4 12.4 0 0 0-4.5-6.2c-2.1-1.5-5-2.2-8.8-2.2a16.51 16.51 0 0 0-8.9 2.1c-2.3 1.5-3.5 3.9-3.5 7.2v71.5c0 2.8.7 4.8 2 6.2 1.5 1.4 3.7 2.1 7 2.1ZM149 116.6l-2.4-1.9a7.4 7.4 0 0 0-9.4.3 19.65 19.65 0 0 1-12.5 4.6h-21.4A37.08 37.08 0 0 0 77 130.5l-1.1 1.2-1.1-1.1a37.25 37.25 0 0 0-26.3-10.9H27a19.59 19.59 0 0 1-12.4-4.6 7.28 7.28 0 0 0-9.4-.3l-2.4 1.9a7.43 7.43 0 0 0-2.8 5.5 7.14 7.14 0 0 0 2.4 5.7 37.28 37.28 0 0 0 24.6 9.5h21.6a19.59 19.59 0 0 1 18.9 14.4v.2c.1.7 1.2 4.4 8.5 4.4s8.4-3.7 8.5-4.4v-.2a19.59 19.59 0 0 1 18.9-14.4H125a37.28 37.28 0 0 0 24.6-9.5 7.42 7.42 0 0 0 2.4-5.7 7.86 7.86 0 0 0-3-5.6Z"
data-name="Layer 1"
/>
</g>
</SVG>
);
}
export default MailPoetIcon;