Skip to content

Commit b0ce78d

Browse files
committed
fix: compatibility for pre wp7
1 parent 7b695ab commit b0ce78d

3 files changed

Lines changed: 32 additions & 5 deletions

File tree

src/compatibility/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import './kadence-theme'
22
import './wp-6-2'
3+
import './wp-pre-7'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* WordPress dependencies
3+
*/
4+
import { addFilter } from '@wordpress/hooks'
5+
6+
/**
7+
* Internal dependencies
8+
*/
9+
import { semverCompare } from '~stackable/util'
10+
import { wpVersion } from 'stackable'
11+
12+
addFilter( 'stackable.block-css.editor-preview-breakpoints', 'stackable/wp-pre-7', breakpoints => {
13+
if ( wpVersion && semverCompare( wpVersion, '<', '7.0' ) ) {
14+
return {
15+
tablet: 781,
16+
mobile: 361,
17+
}
18+
}
19+
20+
return breakpoints
21+
} )

src/components/block-css/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,16 @@ function createCssEdit( selector, rule, value, device = 'desktop', vendorPrefixe
535535
}
536536
css = `\n${ selector } {\n\t${ css }\n}`
537537

538-
// Match the Block Editor's fixed preview widths
539-
// In WordPress 7.0, the preview widths have changed,
540-
// see https://github.com/WordPress/gutenberg/pull/74339
541-
const tabletBreakpoint = 782
542-
const mobileBreakpoint = 480
538+
// Match the Block Editor's fixed preview widths. getMediaQuery subtracts 1,
539+
// so these default values target 781px tablet and 479px mobile in WordPress 7.0.
540+
// https://github.com/WordPress/gutenberg/pull/74339
541+
const { tablet: tabletBreakpoint, mobile: mobileBreakpoint } = applyFilters(
542+
'stackable.block-css.editor-preview-breakpoints',
543+
{
544+
tablet: 782,
545+
mobile: 480,
546+
}
547+
)
543548

544549
const mediaQuery = getMediaQuery( device, tabletBreakpoint, mobileBreakpoint )
545550
if ( mediaQuery ) {

0 commit comments

Comments
 (0)