Skip to content

Commit

Permalink
PLANET-7395: Move Deep Dive block pattern into master theme (#2258)
Browse files Browse the repository at this point in the history
* PLANET-7395: Move Deep Dive block pattern into master theme

- Move all related files

---------

Co-authored-by: Dan Tovbein <[email protected]>
  • Loading branch information
GP-Dan-Tovbein and dantovbein authored May 16, 2024
1 parent 2edfcb2 commit b4c829b
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 14 deletions.
13 changes: 13 additions & 0 deletions assets/src/block-templates/deep-dive/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "planet4-block-templates/deep-dive",
"title": "Deep Dive",
"category": "planet4-block-templates",
"icon": "editor-table",
"textdomain": "planet4-blocks-backend",
"attributes": {
"title": { "type": "string" },
"backgroundColor": { "type": "string" }
}
}
4 changes: 4 additions & 0 deletions assets/src/block-templates/deep-dive/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};
54 changes: 54 additions & 0 deletions assets/src/block-templates/deep-dive/template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import mainThemeUrl from '../main-theme-url';

const {__} = wp.i18n;

const topic = ['core/column', {}, [
['core/group', {className: 'group-stretched-link'}, [
['core/image', {
align: 'center',
className: 'force-no-lightbox force-no-caption is-style-rounded-180',
url: `${mainThemeUrl}/images/placeholders/placeholder-180x180.jpg`,
height: '180px',
width: '180px',
}],
['core/heading', {
level: 5,
textAlign: 'center',
style: {typography: {fontSize: '1rem'}},
className: 'is-style-chevron',
placeholder: __('Enter topic', 'planet4-blocks-backend'),
}],
['core/spacer', {height: '16px'}],
]],
]];

const innerBlocks = ({
title = '',
}) => ([
['core/group', {className: 'container'}, [
['core/spacer', {height: '24px'}],
['core/heading', {
textAlign: 'center',
placeholder: __('Enter title', 'planet4-blocks-backend'),
content: title,
}],
['core/columns', {}, [...Array(4).keys()].map(() => topic)],
]],
]);

const template = ({
title = '',
backgroundColor = 'beige-100',
}) => ([
[
'core/group',
{
className: 'block',
align: 'full',
backgroundColor,
},
innerBlocks({title}),
],
]);

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 @@ -2,10 +2,12 @@ import * as sideImgTextCta from './side-image-with-text-and-cta';
import * as issues from './issues';
import * as realityCheck from './reality-check';
import * as quickLinks from './quick-links';
import * as deepDive from './deep-dive';

export default [
sideImgTextCta,
issues,
realityCheck,
quickLinks,
deepDive,
];
14 changes: 0 additions & 14 deletions assets/src/scss/editorOverrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@
@include table;
}

.wp-block-image {
display: table;

// Mimics the behavior of WP's native '.is-resized' CSS class
.editor-rich-text.block-editor-rich-text {
display: table-caption;
caption-side: bottom;

figcaption {
display: block;
}
}
}

.components-panel__body label {
font-size: 13px;
}
Expand Down
1 change: 1 addition & 0 deletions src/Patterns/BlockPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static function get_list(): array
Issues::class,
RealityCheck::class,
QuickLinks::class,
DeepDive::class,
];
}

Expand Down
42 changes: 42 additions & 0 deletions src/Patterns/DeepDive.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

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

namespace P4\MasterTheme\Patterns;

/**
* Class DeepDive.
*
* @package P4\MasterTheme\Patterns
*/
class DeepDive extends BlockPattern
{
/**
* Returns the pattern name.
*/
public static function get_name(): string
{
return 'p4/deep-dive';
}

/**
* Returns the pattern config.
*
* @param array $params Optional array of parameters for the config.
*/
public static function get_config(array $params = []): array
{
return [
'title' => 'Deep Dive',
'categories' => [ 'planet4' ],
'content' => '
<!-- wp:planet4-block-templates/deep-dive ' . wp_json_encode($params, \JSON_FORCE_OBJECT) . ' /-->
',
];
}
}

0 comments on commit b4c829b

Please sign in to comment.