diff --git a/projects/plugins/jetpack/extensions/blocks/cookie-consent/attributes.js b/projects/plugins/jetpack/extensions/blocks/cookie-consent/attributes.js deleted file mode 100644 index 5b1a21f446af3..0000000000000 --- a/projects/plugins/jetpack/extensions/blocks/cookie-consent/attributes.js +++ /dev/null @@ -1,43 +0,0 @@ -import { __ } from '@wordpress/i18n'; - -export default { - text: { - type: 'string', - source: 'html', - selector: 'p', - default: __( - 'Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use. To find out more, including how to control cookies, see here: Cookie Policy.', - 'jetpack' - ), - }, - style: { - type: 'object', - default: { - color: { - text: 'var(--wp--preset--color--contrast)', - background: 'var(--wp--preset--color--tertiary)', - link: 'var(--wp--preset--color--contrast)', - }, - spacing: { - padding: { - top: '1em', - right: '1em', - bottom: '1em', - left: '1em', - }, - }, - }, - }, - align: { - type: 'string', - default: 'wide', - }, - consentExpiryDays: { - type: 'integer', - default: 365, - }, - showOverlay: { - type: 'boolean', - default: false, - }, -}; diff --git a/projects/plugins/jetpack/extensions/blocks/cookie-consent/block.json b/projects/plugins/jetpack/extensions/blocks/cookie-consent/block.json index 0bb20efeac16e..0ed6e042a5ce3 100644 --- a/projects/plugins/jetpack/extensions/blocks/cookie-consent/block.json +++ b/projects/plugins/jetpack/extensions/blocks/cookie-consent/block.json @@ -64,6 +64,5 @@ "type": "boolean", "default": false } - }, - "editorScript": "file:../editor.js" + } } diff --git a/projects/plugins/jetpack/extensions/blocks/cookie-consent/cookie-consent.php b/projects/plugins/jetpack/extensions/blocks/cookie-consent/cookie-consent.php index c839ece5c92f1..a5d48d40750a3 100644 --- a/projects/plugins/jetpack/extensions/blocks/cookie-consent/cookie-consent.php +++ b/projects/plugins/jetpack/extensions/blocks/cookie-consent/cookie-consent.php @@ -12,9 +12,7 @@ use Automattic\Jetpack\Blocks; use Jetpack_Gutenberg; -const FEATURE_NAME = 'cookie-consent'; -const BLOCK_NAME = 'jetpack/' . FEATURE_NAME; -const COOKIE_NAME = 'eucookielaw'; +const COOKIE_NAME = 'eucookielaw'; /** * Should the block be registered? @@ -48,7 +46,7 @@ function register_block() { } Blocks::jetpack_register_block( - BLOCK_NAME, + __DIR__, array( 'render_callback' => __NAMESPACE__ . '\load_assets' ), array( 'attributes' => array( @@ -89,11 +87,11 @@ function load_assets( $attr, $content ) { /* * Enqueue necessary scripts and styles. */ - Jetpack_Gutenberg::load_assets_as_required( FEATURE_NAME ); + Jetpack_Gutenberg::load_assets_as_required( __DIR__ ); return sprintf( '
%2$s
', - esc_attr( Blocks::classes( FEATURE_NAME, $attr ) ), + esc_attr( Blocks::classes( Blocks::get_block_feature( __DIR__ ), $attr ) ), $content ); } diff --git a/projects/plugins/jetpack/extensions/blocks/cookie-consent/editor.js b/projects/plugins/jetpack/extensions/blocks/cookie-consent/editor.js index d05f403942058..b952d5df5a0eb 100644 --- a/projects/plugins/jetpack/extensions/blocks/cookie-consent/editor.js +++ b/projects/plugins/jetpack/extensions/blocks/cookie-consent/editor.js @@ -1,7 +1,11 @@ -/** - * Internal dependencies - */ -import registerJetpackBlock from '../../shared/register-jetpack-block'; -import { name, settings } from '.'; +import { registerJetpackBlockFromMetadata } from '../../shared/register-jetpack-block'; +import metadata from './block.json'; +import edit from './edit'; +import save from './save'; -registerJetpackBlock( name, settings ); +import './editor.scss'; + +registerJetpackBlockFromMetadata( metadata, { + edit, + save, +} ); diff --git a/projects/plugins/jetpack/extensions/blocks/cookie-consent/icon.js b/projects/plugins/jetpack/extensions/blocks/cookie-consent/icon.js deleted file mode 100644 index 982c5bcca0b07..0000000000000 --- a/projects/plugins/jetpack/extensions/blocks/cookie-consent/icon.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * External dependencies - */ -import { SVG, Path } from '@wordpress/components'; - -export default ( - - - -); diff --git a/projects/plugins/jetpack/extensions/blocks/cookie-consent/index.js b/projects/plugins/jetpack/extensions/blocks/cookie-consent/index.js deleted file mode 100644 index 12976d3e91a51..0000000000000 --- a/projects/plugins/jetpack/extensions/blocks/cookie-consent/index.js +++ /dev/null @@ -1,61 +0,0 @@ -import { __ } from '@wordpress/i18n'; -import { getIconColor } from '../../shared/block-icons'; -import attributes from './attributes'; -import edit from './edit'; -import icon from './icon'; -import save from './save'; - -/** - * Style dependencies - */ -import './editor.scss'; - -export const name = 'cookie-consent'; -export const title = __( 'Cookie Consent', 'jetpack' ); -export const cookieName = 'eucookielaw'; -export const settings = { - title, - description: __( - 'Displays a customizable cookie consent banner. To display this block on all pages of your site, please add it inside a Template Part that is present on all your templates, like a Header or a Footer.', - 'jetpack' - ), - icon: { - src: icon, - foreground: getIconColor(), - }, - category: 'grow', - keywords: [ - 'cookie', - 'consent', - 'privacy', - 'GDPR', - 'EU', - __( 'cookies', 'jetpack' ), - __( 'privacy', 'jetpack' ), - __( 'EU', 'jetpack' ), - ], - supports: { - align: [ 'left', 'right', 'wide', 'full' ], - alignWide: true, - anchor: false, - color: { - gradients: true, - link: true, - }, - spacing: { - padding: true, - }, - customClassName: true, - className: true, - html: false, - lock: false, - multiple: false, - reusable: false, - }, - edit, - save, - attributes, - example: { - attributes: {}, - }, -}; diff --git a/projects/plugins/jetpack/extensions/blocks/cookie-consent/style.scss b/projects/plugins/jetpack/extensions/blocks/cookie-consent/style.scss index ea1f4eb0bce0b..8d1907bf8669a 100644 --- a/projects/plugins/jetpack/extensions/blocks/cookie-consent/style.scss +++ b/projects/plugins/jetpack/extensions/blocks/cookie-consent/style.scss @@ -37,7 +37,7 @@ } &.alignright { - right: 10px; + left: 10px; margin-left: auto !important; } diff --git a/projects/plugins/jetpack/extensions/blocks/cookie-consent/test/validate.js b/projects/plugins/jetpack/extensions/blocks/cookie-consent/test/validate.js index b72589b60b8dc..2582ec88de967 100644 --- a/projects/plugins/jetpack/extensions/blocks/cookie-consent/test/validate.js +++ b/projects/plugins/jetpack/extensions/blocks/cookie-consent/test/validate.js @@ -1,5 +1,7 @@ -import { name, settings } from '../'; import runBlockFixtureTests from '../../../shared/test/block-fixtures'; +import metadata from '../block.json'; -const blocks = [ { name: `jetpack/${ name }`, settings } ]; -runBlockFixtureTests( `jetpack/${ name }`, blocks, __dirname ); +const { name } = metadata; +const blocks = [ { name, settings: metadata } ]; + +runBlockFixtureTests( name, blocks, __dirname );