Skip to content

Commit

Permalink
PLANET-7398 Move Quick Links block pattern into master theme (#2276)
Browse files Browse the repository at this point in the history
- Moved all necessary files for Quick Links to Master theme
  • Loading branch information
Osong-Michael committed May 7, 2024
1 parent 5e112b6 commit 0d47257
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 0 deletions.
12 changes: 12 additions & 0 deletions assets/src/block-templates/quick-links/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "planet4-block-templates/quick-links",
"title": "Quick Links",
"category": "planet4-block-templates",
"textdomain": "planet4-blocks-backend",
"attributes": {
"title": { "type": "string" },
"backgroundColor": { "type": "string" }
}
}
4 changes: 4 additions & 0 deletions assets/src/block-templates/quick-links/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};
45 changes: 45 additions & 0 deletions assets/src/block-templates/quick-links/template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import mainThemeUrl from '../main-theme-url';

const {__} = wp.i18n;

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

const template = ({
title = '',
backgroundColor = 'beige-100',
}) => ([
['core/group', {
className: 'block',
align: 'full',
backgroundColor,
}, [
['core/group', {className: 'container'}, [
['core/spacer', {height: '24px'}],
['core/heading', {level: 4, placeholder: __('Enter title', 'planet4-blocks-backend'), content: title}],
['core/columns', {
isStackedOnMobile: false,
className: 'is-style-mobile-carousel',
},
[...Array(5).keys()].map(() => category)],
]],
]],
]);

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
@@ -1,9 +1,11 @@
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';

export default [
sideImgTextCta,
issues,
realityCheck,
quickLinks,
];
1 change: 1 addition & 0 deletions src/Patterns/BlockPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static function get_list(): array
SideImageWithTextAndCta::class,
Issues::class,
RealityCheck::class,
QuickLinks::class,
];
}

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

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

namespace P4\MasterTheme\Patterns;

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

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

0 comments on commit 0d47257

Please sign in to comment.