Skip to content

Commit

Permalink
Refactor Cookie Consent block registration
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieur-z committed Sep 15, 2023
1 parent db8ee13 commit 12505ae
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 139 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,5 @@
"type": "boolean",
"default": false
}
},
"editorScript": "file:../editor.js"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -48,7 +46,7 @@ function register_block() {
}

Blocks::jetpack_register_block(
BLOCK_NAME,
__DIR__,
array( 'render_callback' => __NAMESPACE__ . '\load_assets' ),
array(
'attributes' => array(
Expand Down Expand Up @@ -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(
'<div class="%1$s">%2$s</div>',
esc_attr( Blocks::classes( FEATURE_NAME, $attr ) ),
esc_attr( Blocks::classes( Blocks::get_block_feature( __DIR__ ), $attr ) ),
$content
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
} );
17 changes: 0 additions & 17 deletions projects/plugins/jetpack/extensions/blocks/cookie-consent/icon.js

This file was deleted.

61 changes: 0 additions & 61 deletions projects/plugins/jetpack/extensions/blocks/cookie-consent/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}

&.alignright {
right: 10px;
left: 10px;
margin-left: auto !important;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 );

0 comments on commit 12505ae

Please sign in to comment.