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

fix (icon label): change icon gap #3209

Merged
merged 10 commits into from
Jul 11, 2024
Merged

fix (icon label): change icon gap #3209

merged 10 commits into from
Jul 11, 2024

Conversation

mxkae
Copy link
Contributor

@mxkae mxkae commented Jun 13, 2024

fixes #3126

Copy link

github-actions bot commented Jun 13, 2024

🤖 Pull request artifacts

file commit
pr3209-stackable-3209-merge.zip 113ac7e

github-actions bot added a commit that referenced this pull request Jun 13, 2024
Copy link
Contributor

@bfintal bfintal left a comment

Choose a reason for hiding this comment

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

While this should work, I want to suggest whether we can try a different (cleaner) approach.

Approach:

  • We create a new attribute iconGap2 that holds the new value for iconGap, moving forward iconGap will no longer be used, but it will still be kept in the attribute definition
  • In PHP, in render_block if we encounter the block that has an iconGap attribute, but doesn't have an iconGap2, we:
    • Calculate for the new icon gap value, then replace the old CSS with the updated CSS
    • Add a special class to say that this block should use the old css flex: 0 0 64px
  • In the editor JS, we have this deprecation entry: isEligible returns true if the block contains a value for iconGap, the migrate the value from iconGap to iconGap2

Pros of approach:

  • No need to create a new version attribute
  • No need for a new class name

github-actions bot added a commit that referenced this pull request Jun 19, 2024
github-actions bot added a commit that referenced this pull request Jun 19, 2024
Copy link
Contributor

@bfintal bfintal left a comment

Choose a reason for hiding this comment

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

Just some code organization suggestions

$attributes = $block[ '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' ] );
Copy link
Contributor

Choose a reason for hiding this comment

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

Check first for the presence of the elements in $block['innerBlocks'] to prevent fatal errors.

@@ -0,0 +1,25 @@
<?php

// Exit if accessed directly.
Copy link
Contributor

Choose a reason for hiding this comment

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

can we rename this file to deprecated.php or something so we can denote that it's for deprecation purposes?

@@ -37,6 +37,11 @@ export const attributes = ( version = VERSION ) => {
stkResponsive: true,
default: '',
},
iconGap2: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment on iconGap that it's deprecated but kept here for migration purposes

@@ -26,6 +26,7 @@ const Styles = props => {

return (
<>
{ /* For the old icon gap */ }
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe you should be able to remove the BlockCss entry for the old iconGap here and the block should not error out.

// Default width of the icon width.
.stk-block-icon {
flex: 0 0 64px;
// For old icon gap
Copy link
Contributor

Choose a reason for hiding this comment

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

can you move this css to the bottom (isolating it from the rest of the "current" css code) and then label it as "deprecated"

github-actions bot added a commit that referenced this pull request Jun 21, 2024
Comment on lines 2 to 6
flex: 0 0 0;
}
// Icon label can collapse in mobile in the editor.
.stk-preview-device-mobile .stk-block-icon-label .block-editor-block-list__layout [data-type="stackable/icon"] {
flex: 0 0 64px;
flex: 0 0 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it work if we remove the flex definition completely since this is for the old 0 0 64px?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it still needs the flex, but i changed it to flex: 0 instead.

github-actions bot added a commit that referenced this pull request Jun 24, 2024
@andeng1106
Copy link

@mxkae Issue with Icon Gap has now been fixed.

One remaining issue:

  • Upon updating to the PR 3209 build, Icon Gap settings applied on tablet and mobile is missing/reset
Screen.Recording.2024-06-24.at.3.mp4

github-actions bot added a commit that referenced this pull request Jun 25, 2024
@bfintal bfintal merged commit 7c2d8f7 into develop Jul 11, 2024
1 of 6 checks passed
@bfintal bfintal deleted the fix/3126-icon-label-gap branch July 11, 2024 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Icon Label block Icon Gap issue
3 participants