From a8877c2e29f2933d5a4dd2c60e1ecb0c8e08dac1 Mon Sep 17 00:00:00 2001 From: Dan Tovbein Date: Thu, 16 May 2024 13:33:23 -0300 Subject: [PATCH] PLANET-7396: Move Highlighted CTA block pattern into master theme (#2259) * Ref: https://jira.greenpeace.org/browse/PLANET-7396 PLANET-7395: Move HighlightedCTA block pattern into master theme - Move all related files --------- Co-authored-by: Dan Tovbein --- .../highlighted-cta/block.json | 11 +++++ .../block-templates/highlighted-cta/index.js | 4 ++ .../highlighted-cta/template.js | 47 +++++++++++++++++++ assets/src/block-templates/template-list.js | 2 + src/Patterns/BlockPattern.php | 1 + src/Patterns/HighlightedCta.php | 42 +++++++++++++++++ 6 files changed, 107 insertions(+) create mode 100644 assets/src/block-templates/highlighted-cta/block.json create mode 100644 assets/src/block-templates/highlighted-cta/index.js create mode 100644 assets/src/block-templates/highlighted-cta/template.js create mode 100644 src/Patterns/HighlightedCta.php diff --git a/assets/src/block-templates/highlighted-cta/block.json b/assets/src/block-templates/highlighted-cta/block.json new file mode 100644 index 0000000000..8964d82b60 --- /dev/null +++ b/assets/src/block-templates/highlighted-cta/block.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 2, + "name": "planet4-block-templates/highlighted-cta", + "title": "Highlighted CTA", + "category": "planet4-block-templates", + "textdomain": "planet4-blocks-backend", + "attributes": { + "titlePlaceholder": { "type": "string" } + } +} diff --git a/assets/src/block-templates/highlighted-cta/index.js b/assets/src/block-templates/highlighted-cta/index.js new file mode 100644 index 0000000000..8b8d0ab4e6 --- /dev/null +++ b/assets/src/block-templates/highlighted-cta/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/highlighted-cta/template.js b/assets/src/block-templates/highlighted-cta/template.js new file mode 100644 index 0000000000..20ad6d7565 --- /dev/null +++ b/assets/src/block-templates/highlighted-cta/template.js @@ -0,0 +1,47 @@ +import mainThemeUrl from '../main-theme-url'; + +const {__} = wp.i18n; + +const template = ({ + titlePlaceholder = __('Enter text', 'planet4-blocks-backend'), +}) => [ + [ + 'core/group', + { + className: 'block', + backgroundColor: 'dark-green-800', + }, + [ + ['core/spacer', {height: '40px'}], + ['core/image', { + align: 'center', + className: 'force-no-lightbox force-no-caption', + url: `${mainThemeUrl}/images/placeholders/placeholder-80x80.jpg`, + width: '80px', + height: '80px', + style: { + spacing: { + margin: { + top: '0', + bottom: '0', + }, + }, + }, + }], + ['core/spacer', {height: '32px'}], + ['core/heading', { + textAlign: 'center', + level: 3, + placeholder: titlePlaceholder, + textColor: 'white', + }], + ['core/spacer', {height: '24px'}], + ['core/buttons', {layout: {type: 'flex', justifyContent: 'center'}}, [ + ['core/button', {className: 'is-style-cta'}], + ]], + ['core/spacer', {height: '40px'}], + ], + ], +]; + +export default template; diff --git a/assets/src/block-templates/template-list.js b/assets/src/block-templates/template-list.js index 037dc5908c..ddb0de22ec 100644 --- a/assets/src/block-templates/template-list.js +++ b/assets/src/block-templates/template-list.js @@ -3,6 +3,7 @@ import * as issues from './issues'; import * as realityCheck from './reality-check'; import * as quickLinks from './quick-links'; import * as deepDive from './deep-dive'; +import * as highlightedCta from './highlighted-cta'; export default [ sideImgTextCta, @@ -10,4 +11,5 @@ export default [ realityCheck, quickLinks, deepDive, + highlightedCta, ]; diff --git a/src/Patterns/BlockPattern.php b/src/Patterns/BlockPattern.php index f5a1128c09..4277095c5e 100644 --- a/src/Patterns/BlockPattern.php +++ b/src/Patterns/BlockPattern.php @@ -46,6 +46,7 @@ public static function get_list(): array RealityCheck::class, QuickLinks::class, DeepDive::class, + HighlightedCta::class, ]; } diff --git a/src/Patterns/HighlightedCta.php b/src/Patterns/HighlightedCta.php new file mode 100644 index 0000000000..ea857ffa24 --- /dev/null +++ b/src/Patterns/HighlightedCta.php @@ -0,0 +1,42 @@ + 'Highlighted CTA', + 'categories' => [ 'planet4' ], + 'content' => ' + + ', + ]; + } +}