Skip to content

Commit

Permalink
feat(mjml): handle social icons block aligment options (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek authored Jul 7, 2020
1 parent 99f2f1f commit ce10875
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 6 additions & 2 deletions includes/class-newspack-newsletters-renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,18 @@ private static function render_mjml_component( $block, $is_in_column = false, $i
);

$social_wrapper_attrs = array(
'align' => isset( $attrs['align'] ) && 'center' == $attrs['align'] ? 'center' : 'left',
'icon-size' => '22px',
'mode' => 'horizontal',
'padding' => '0',
'border-radius' => '999px',
'icon-padding' => '8px',
);
$markup = '<mj-social ' . self::array_to_attributes( $social_wrapper_attrs ) . '>';
if ( isset( $attrs['align'] ) ) {
$social_wrapper_attrs['align'] = $attrs['align'];
} else {
$social_wrapper_attrs['align'] = 'left';
}
$markup = '<mj-social ' . self::array_to_attributes( $social_wrapper_attrs ) . '>';
foreach ( $inner_blocks as $link_block ) {
if ( isset( $link_block['attrs']['url'] ) ) {
$url = $link_block['attrs']['url'];
Expand Down
7 changes: 1 addition & 6 deletions src/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ domReady( () => {

addFilter( 'blocks.registerBlockType', 'newspack-newsletters/core-blocks', ( settings, name ) => {
/* Remove left/right alignment options wherever possible */
if (
'core/paragraph' === name ||
'core/social-links' === name ||
'core/buttons' === name ||
'core/columns' === name
) {
if ( 'core/paragraph' === name || 'core/buttons' === name || 'core/columns' === name ) {
settings.supports = { ...settings.supports, align: [] };
}
if ( 'core/group' === name ) {
Expand Down

0 comments on commit ce10875

Please sign in to comment.