Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLANET-6638: Issues block pattern #811

Merged
merged 3 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions admin/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,33 @@ wp.domReady(() => {
];

registerBlockStyle('core/button', styles);

['core/media-text', 'core/group', 'core/column'].forEach(
block => registerBlockStyle(block, [
{
name: 'small-padding',
label: __('Small padding', 'planet4-blocks-backend'),
}, {
name: 'medium-padding',
label: __('Medium padding', 'planet4-blocks-backend'),
}, {
name: 'large-padding',
label: __('Large padding', 'planet4-blocks-backend'),
},
]),
);

['core/group'].forEach(block => {
registerBlockStyle(block, {
name: 'space-evenly',
label: __('Space evenly', 'planet4-blocks-backend'),
});
});

['core/paragraph'].forEach(block => {
Copy link
Contributor Author

@GP-Dan-Tovbein GP-Dan-Tovbein May 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This style allows to editors to choose the Roboto font family as default.

registerBlockStyle(block, {
name: 'roboto-font-family',
label: __('Roboto font family', 'planet4-blocks-backend'),
});
});
});
34 changes: 34 additions & 0 deletions assets/src/styles/blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,37 @@
// Other
@import "blocks/WideBlocks";
@import "blocks/Editor";

.is-style-small-padding {
padding: 8px;
}

.is-style-medium-padding {
padding: 16px;
}

.is-style-large-padding {
padding: 32px;
}

.is-style-space-evenly {
& > * {
flex-grow: 1;
flex-basis: 100%;
align-self: stretch;

@include medium-and-up {
flex-grow: 0;
flex-basis: calc(50% - calc(var(--wp--style--block-gap, 2em) / 2));
}

@include large-and-up {
flex-basis: 0;
flex-grow: 1;
}
}
}

.is-style-roboto-font-family {
font-family: $roboto;
}
1 change: 1 addition & 0 deletions classes/patterns/class-block-pattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static function register_all() {
SideImageWithTextAndCta::class,
HighlightedCta::class,
RealityCheck::class,
Issues::class,
];

/**
Expand Down
102 changes: 102 additions & 0 deletions classes/patterns/class-issues.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php
/**
* Issues class.
*
* @package P4GBKS
* @since 0.1
*/

namespace P4GBKS\Patterns;

/**
* Issues pattern includes:
* Column, Image, Heading, Paragraph, Media & Text.
*
* @package P4GBKS\Patterns
*/
class Issues extends Block_Pattern {

/**
* Returns the pattern name.
*/
public static function get_name(): string {
return 'p4/issues';
}

/**
* Returns the template for one media-text.
*/
public static function get_media_text_template(): string {

return '
<!-- wp:media-text {"mediaWidth":15,"mediaSizeSlug":"thumbnail","isStackedOnMobile":false,"verticalAlignment":"center","imageFill":false,"backgroundColor":"white","className":"is-style-large-padding"} -->
<div class="wp-block-media-text alignwide is-vertically-aligned-center has-white-background-color is-style-large-padding has-background" style="grid-template-columns:15% auto">
<figure class="wp-block-media-text__media"></figure>
<div class="wp-block-media-text__content">
<!-- wp:paragraph {"align":"left","placeholder":"' . __( 'Enter text', 'planet4-blocks-backend' ) . '","style":{"typography":{"fontSize":"1rem","fontStyle":"normal","fontWeight":"700"}},"className":"is-style-roboto-font-family"} -->
<p class="has-text-align-left is-style-roboto-font-family" style="font-size:1rem;font-style:normal;font-weight:700"></p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:media-text -->
';
}

/**
* Returns the pattern config.
*/
public static function get_config(): array {
return [
'title' => __( 'Issues', 'planet4-blocks-backend' ),
'categories' => [ 'planet4' ],
'content' => '
<!-- wp:group {"align":"full","backgroundColor":"grey-10"} -->
<div class="wp-block-group alignfull has-grey-10-background-color has-background">
Inwerpsel marked this conversation as resolved.
Show resolved Hide resolved

<!-- wp:group {"className":"container"} -->
<div class="wp-block-group container">

<!-- wp:spacer {"height":"60px"} -->
<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:heading {"textAlign":"center","level":1, "placeholder":"' . __( 'Enter title', 'planet4-blocks-backend' ) . '"} -->
<h1 class="has-text-align-center"></h1>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"center", "placeholder":"' . __( 'Enter description', 'planet4-blocks-backend' ) . '"} -->
<p class="has-text-align-center"></p>
<!-- /wp:paragraph -->

<!-- wp:spacer {"height":"37px"} -->
<div style="height:37px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:group {"className":"is-style-space-evenly","layout":{"type":"flex","allowOrientation":false}} -->
<div class="wp-block-group is-style-space-evenly">
' . self::get_media_text_template() . '
' . self::get_media_text_template() . '
' . self::get_media_text_template() . '
' . self::get_media_text_template() . '
</div>
<!-- /wp:group -->

<!-- wp:spacer {"height":"37px"} -->
<div style="height:37px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:buttons {"placeholder":"' . __( 'Enter text', 'planet4-blocks-backend' ) . '","layout":{"type":"flex","justifyContent":"center"}} -->
<div class="wp-block-buttons">
<!-- wp:button -->
<div class="wp-block-button is-style-secondary"><a class="wp-block-button__link"></a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->

<!-- wp:spacer {"height":"69px"} -->
<div style="height:69px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

</div><!-- /wp:group -->
</div><!-- /wp:group -->
',
];
}
}