From aeb619b3912724b655889de98595cdf7ea598186 Mon Sep 17 00:00:00 2001 From: Dan Tovbein Date: Mon, 26 Aug 2024 08:29:38 -0300 Subject: [PATCH] PLANET-7548: Move Action pattern block to theme (#2338) Ref: https://jira.greenpeace.org/browse/PLANET-7548 Include all related files Co-authored-by: Dan Tovbein --- assets/src/block-templates/action/block.json | 9 ++++ assets/src/block-templates/action/index.js | 4 ++ assets/src/block-templates/action/template.js | 38 +++++++++++++++++ assets/src/block-templates/template-list.js | 2 + src/Patterns/Action.php | 42 +++++++++++++++++++ src/Patterns/BlockPattern.php | 1 + 6 files changed, 96 insertions(+) create mode 100644 assets/src/block-templates/action/block.json create mode 100644 assets/src/block-templates/action/index.js create mode 100644 assets/src/block-templates/action/template.js create mode 100644 src/Patterns/Action.php diff --git a/assets/src/block-templates/action/block.json b/assets/src/block-templates/action/block.json new file mode 100644 index 0000000000..2da27a02cf --- /dev/null +++ b/assets/src/block-templates/action/block.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 2, + "name": "planet4-block-templates/action", + "title": "Action", + "category": "planet4-block-templates", + "icon": "editor-table", + "textdomain": "planet4-blocks-backend" +} diff --git a/assets/src/block-templates/action/index.js b/assets/src/block-templates/action/index.js new file mode 100644 index 0000000000..8b8d0ab4e6 --- /dev/null +++ b/assets/src/block-templates/action/index.js @@ -0,0 +1,4 @@ +import metadata from './block.json'; +import template from './template'; + +export {metadata, template}; diff --git a/assets/src/block-templates/action/template.js b/assets/src/block-templates/action/template.js new file mode 100644 index 0000000000..643d3b2a35 --- /dev/null +++ b/assets/src/block-templates/action/template.js @@ -0,0 +1,38 @@ +import gravityFormWithText from '../templates/gravity-form-with-text'; + +const {__} = wp.i18n; + +const template = () => ([ + ['core/group', {className: 'block'}, [ + gravityFormWithText('white'), + ['core/group', { + backgroundColor: 'beige-100', + align: 'full', + style: { + spacing: { + padding: { + top: '80px', + bottom: '80px', + }, + }, + }, + }, [ + ['core/group', {className: 'container'}, [ + ['planet4-block-templates/side-image-with-text-and-cta', { + title: __('The problem', 'planet4-blocks'), + mediaPosition: 'right', + }], + ]], + ]], + ['planet4-blocks/covers', { + cover_type: 'take-action', + }], + ['core/separator', {backgroundColor: 'grey-20'}], + ['planet4-block-templates/quick-links', { + title: __('Explore by topics', 'planet4-blocks'), + backgroundColor: 'white', + }], + ]], +]); + +export default template; diff --git a/assets/src/block-templates/template-list.js b/assets/src/block-templates/template-list.js index 209a26195d..9a9e8eaa47 100644 --- a/assets/src/block-templates/template-list.js +++ b/assets/src/block-templates/template-list.js @@ -11,6 +11,7 @@ import * as homepage from './homepage'; import * as getInformed from './get-informed'; import * as deepDiveTopic from './deep-dive-topic'; import * as campaign from './campaign'; +import * as action from './action'; export default [ sideImgTextCta, @@ -26,4 +27,5 @@ export default [ getInformed, deepDiveTopic, campaign, + action, ]; diff --git a/src/Patterns/Action.php b/src/Patterns/Action.php new file mode 100644 index 0000000000..58b26aaca6 --- /dev/null +++ b/src/Patterns/Action.php @@ -0,0 +1,42 @@ + 'Action', + 'categories' => [ 'layouts' ], + 'blockTypes' => [ 'core/post-content' ], + 'postTypes' => [ 'page', 'p4_action', 'campaign' ], + 'content' => ' + + ', + ]; + } +} diff --git a/src/Patterns/BlockPattern.php b/src/Patterns/BlockPattern.php index 86742a92a2..75456e457e 100644 --- a/src/Patterns/BlockPattern.php +++ b/src/Patterns/BlockPattern.php @@ -42,6 +42,7 @@ public static function get_list(): array { return [ BlankPage::class, + Action::class, Campaign::class, DeepDive::class, DeepDiveTopic::class,