Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/block/columns/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@import "common";
@import "./deprecated-style";

.stk--flex:not(.stk--column-wrap-desktop) > .stk-block-column {
// Older Feature Grid saves put the desktop wrap marker on the block wrapper.
.stk--flex:not(.stk--column-wrap-desktop):not(.stk-block-feature-grid.stk--column-wrap-desktop > .stk-block-content) > .stk-block-column {
width: fit-content;
flex: 0 1 auto !important;
min-width: 24px;
Expand Down
33 changes: 33 additions & 0 deletions src/block/feature-grid/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,33 @@ addFilter( 'stackable.feature-grid.save.blockClassNames', 'stackable/3.13.3', (
return classnames
} )

// Column wrapping now adds the stk--column-wrap-desktop class to the content
// wrapper. For older saves, keep the marker on the block wrapper so existing
// Feature Grid markup validates without cloning the Save component.
addFilter( 'stackable.feature-grid.save.blockClassNames', 'stackable/3.19.9', ( output, props ) => {
if ( compareVersions( props.version, '3.19.8' ) === 0 ) {
return [
...output,
{
'stk--column-wrap-desktop': props.attributes.columnWrapDesktop,
},
]
}

return output
} )

addFilter( 'stackable.feature-grid.save.contentClassNames', 'stackable/3.19.9', ( classes, props ) => {
if ( compareVersions( props.version, '3.19.8' ) === 0 ) {
// The old save shape did not include the wrap marker on stk-block-content.
return classes.filter( className => {
return ! className?.[ 'stk--column-wrap-desktop' ]
} )
}

return classes
} )

// Version 3.1.0 Deprecations
addFilter( 'stackable.feature-grid.save.blockClassNames', 'stackable/3.1.0', ( output, props ) => {
if ( compareVersions( props.version, '3.1.0' ) === 1 ) {
Expand All @@ -61,6 +88,12 @@ addFilter( 'stackable.feature-grid.save.blockClassNames', 'stackable/3.1.0', ( o
} )

const deprecated = [
{
// Support Feature Grid blocks saved before the column wrapping marker
// moved from the block wrapper to the content wrapper.
attributes: attributes( '3.19.8' ),
save: withVersion( '3.19.8' )( Save ),
},
{
// Handle the migration of shadow attributes with the change of type in 3.15.3
attributes: attributes( '3.16.2' ),
Expand Down
10 changes: 6 additions & 4 deletions src/block/feature-grid/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,17 @@ const Edit = props => {
rowClass,
separatorClass,
columnTooltipClass,
], {
'stk--column-wrap-desktop': props.attributes.columnWrapDesktop,
} )
] )

// The wrap marker belongs on the flex wrapper so justified wrapped columns
// keep their configured widths, matching the Columns block behavior.
const contentClassNames = classnames( [
'stk-inner-blocks',
blockAlignmentClass,
'stk-block-content',
], getContentAlignmentClasses( props.attributes ) )
], {
'stk--column-wrap-desktop': props.attributes.columnWrapDesktop,
}, getContentAlignmentClasses( props.attributes ) )

// Generate the CSS styles for the block.
const blockCss = useBlockCssGenerator( {
Expand Down
25 changes: 16 additions & 9 deletions src/block/feature-grid/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,26 @@ export const Save = props => {
'stk-block-columns', // We need to add the columns class to make fit all and column gap to work properly.
responsiveClass,
separatorClass,
{
'stk--column-wrap-desktop': attributes.columnWrapDesktop,
},
],
], props )
)

const contentClassNames = classnames( [
rowClass,
'stk-inner-blocks',
blockAlignmentClass,
'stk-block-content',
], getContentAlignmentClasses( attributes ) )
// The wrap marker belongs on the flex wrapper so justified wrapped columns
// keep their configured widths, matching the Columns block behavior.
const contentClassNames = classnames(
applyFilters( 'stackable.feature-grid.save.contentClassNames', [
[
rowClass,
'stk-inner-blocks',
blockAlignmentClass,
'stk-block-content',
],
{
'stk--column-wrap-desktop': attributes.columnWrapDesktop,
},
getContentAlignmentClasses( attributes ),
], props )
)

return (
<BlockDiv.Content
Expand Down
5 changes: 0 additions & 5 deletions src/block/feature-grid/style.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
@import "common";

.stk-block-feature-grid.stk--column-wrap-desktop .stk--flex > .stk-block-column,
.stk-block-feature-grid.stk--column-wrap-desktop .stk--flex > * > * > [data-type="stackable/column"] {
flex: var(--stk-flex-grow, 1) 1 calc(100% - var(--stk-column-gap, 0px) * 0 / 1) !important;
}
Loading