Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mxkae committed Jun 21, 2024
1 parent b286ae5 commit 5f77b68
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 34 deletions.
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function is_frontend() {
require_once( plugin_dir_path( __FILE__ ) . 'src/block-components/alignment/index.php' );
require_once( plugin_dir_path( __FILE__ ) . 'src/block/columns/index.php' );
require_once( plugin_dir_path( __FILE__ ) . 'src/block/timeline/index.php' );
require_once( plugin_dir_path( __FILE__ ) . 'src/block/icon-label/index.php' );
require_once( plugin_dir_path( __FILE__ ) . 'src/block/icon-label/deprecated.php' );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
function stackable_render_block_icon_label( $block_content, $block ) {
$attributes = $block[ 'attrs' ];

// check if inner blocks contain an icon block
if ( ! isset( $block[ 'innerBlocks' ][0] ) || ! isset( $block[ 'innerBlocks' ][0]['blockName'] ) || $block[ 'innerBlocks' ][0]['blockName'] !== 'stackable/icon' ) {
return $block_content;
}

$icon_block_attrs = $block[ 'innerBlocks' ][0]['attrs'];

// check if the block uses the old icon gap attribute
$use_old_styles = ( isset( $attributes[ 'iconGap' ] ) || isset( $block[ 'innerBlocks' ][0]['attrs']['iconSize'] ) ) && ! isset( $attributes[ 'iconGap2' ] );
$use_old_styles = ( isset( $attributes[ 'iconGap' ] ) || isset( $icon_block_attrs['iconSize'] ) ) && ! isset( $attributes[ 'iconGap2' ] );

if ( $use_old_styles ) {
return preg_replace( '/stk-block-icon-label/i', 'stk-block-icon-label stk-block-icon-label--use-flex-basis', $block_content );
Expand Down
1 change: 1 addition & 0 deletions src/block/icon-label/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const attributes = ( version = VERSION ) => {
ConditionalDisplay.addAttributes( attrObject )
attrObject.add( {
attributes: {
// iconGap is deprecated but is kept for migration purposes
iconGap: {
type: 'number',
stkResponsive: true,
Expand Down
21 changes: 0 additions & 21 deletions src/block/icon-label/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,6 @@ const Styles = props => {

return (
<>
{ /* For the old icon gap */ }
<BlockCss
{ ...propsToPass }
renderIn="save"
selector=".stk-block-icon"
attrName="iconGap"
key="iconGap-save"
styleRule="flexBasis"
format="%spx"
responsive="all"
/>
<BlockCss
{ ...propsToPass }
renderIn="edit"
selector={ `.stk-inner-blocks [data-block][data-type="stackable/icon"]` }
attrName="iconGap"
key="iconGap"
styleRule="flexBasis"
format="%spx"
responsive="all"
/>
<BlockCss
{ ...propsToPass }
renderIn="save"
Expand Down
22 changes: 11 additions & 11 deletions src/block/icon-label/style.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
.stk-block-icon-label {
// For old icon gap
&.stk-block-icon-label--use-flex-basis {
// Default width of the icon width.
.stk-block-icon {
flex: 0 0 64px;
}
.stk-inner-blocks {
gap: 0;
}
}

// used by iconGap2
.stk-inner-blocks {
gap: 28px;
Expand Down Expand Up @@ -37,3 +26,14 @@
width: inherit;
}
}

// Deprecated styles
.stk-block-icon-label.stk-block-icon-label--use-flex-basis {
// Default width of the icon width.
.stk-block-icon {
flex: 0 0 64px;
}
.stk-inner-blocks {
gap: 0;
}
}

0 comments on commit 5f77b68

Please sign in to comment.