Skip to content

Commit

Permalink
PLANET-7548: Move Action pattern block to theme (#2338)
Browse files Browse the repository at this point in the history
Ref: https://jira.greenpeace.org/browse/PLANET-7548

Include all related files

Co-authored-by: Dan Tovbein <[email protected]>
  • Loading branch information
GP-Dan-Tovbein and dantovbein authored Aug 26, 2024
1 parent 552837e commit aeb619b
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 0 deletions.
9 changes: 9 additions & 0 deletions assets/src/block-templates/action/block.json
Original file line number Diff line number Diff line change
@@ -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"
}
4 changes: 4 additions & 0 deletions assets/src/block-templates/action/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import metadata from './block.json';
import template from './template';

export {metadata, template};
38 changes: 38 additions & 0 deletions assets/src/block-templates/action/template.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions assets/src/block-templates/template-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -26,4 +27,5 @@ export default [
getInformed,
deepDiveTopic,
campaign,
action,
];
42 changes: 42 additions & 0 deletions src/Patterns/Action.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* Action pattern class.
*
* @package P4\MasterTheme\Patterns
* @since 0.1
*/

namespace P4\MasterTheme\Patterns;

/**
* Class Action.
*
* @package P4\MasterTheme\Patterns
*/
class Action extends BlockPattern
{
/**
* @inheritDoc
*/
public static function get_name(): string
{
return 'p4/action-pattern-layout';
}

/**
* @inheritDoc
*/
public static function get_config($params = []): array
{
return [
'title' => 'Action',
'categories' => [ 'layouts' ],
'blockTypes' => [ 'core/post-content' ],
'postTypes' => [ 'page', 'p4_action', 'campaign' ],
'content' => '
<!-- wp:planet4-block-templates/action ' . wp_json_encode($params, \JSON_FORCE_OBJECT) . ' /-->
',
];
}
}
1 change: 1 addition & 0 deletions src/Patterns/BlockPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static function get_list(): array
{
return [
BlankPage::class,
Action::class,
Campaign::class,
DeepDive::class,
DeepDiveTopic::class,
Expand Down

0 comments on commit aeb619b

Please sign in to comment.