-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block spacing: block-level axial gap block support (#37736)
* Initial commit: splitting the gap value to allow for axial gap values * Checking for object. Now passing complete object to box control. * Providing a default value for split gap values, where one is `undefined`. * This is the first commit that switches the blockGap over to use to an object. We're using the `top` and `left` properties of the BoxControl next value to represent row and column values. Reverting some block.json changes. Ensuring that we cater for blockGap string values. Reverting some block.json changes. Ensuring that we cater for blockGap string values. Adding tests. * margin-top should take a single value * null coalescing operator (??) is not present in PHP * Checking for gap array items before using them. * Using `--wp--style--block-gap` as the fallback for split values * Returning null instead of the argument in getGapCSSValue and updated tests Added comment to explain how we build and pass the boxcontrol component value. * Rolling back using the gap CSS var as a fallback since the CSS var can theoretically be something like "24px 54px" or some other manifestation of the shorthand value.
- Loading branch information
Showing
6 changed files
with
153 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getGapCSSValue } from '../gap'; | ||
|
||
describe( 'gap', () => { | ||
describe( 'getGapCSSValue()', () => { | ||
it( 'should return `null` if argument is falsey', () => { | ||
expect( getGapCSSValue( undefined ) ).toBeNull(); | ||
expect( getGapCSSValue( '' ) ).toBeNull(); | ||
} ); | ||
|
||
it( 'should return single value for gap if argument is valid string', () => { | ||
expect( getGapCSSValue( '88rem' ) ).toEqual( '88rem' ); | ||
} ); | ||
|
||
it( 'should return single value for gap if row and column are the same', () => { | ||
const blockGapValue = { | ||
top: '88rem', | ||
left: '88rem', | ||
}; | ||
expect( getGapCSSValue( blockGapValue ) ).toEqual( '88rem' ); | ||
} ); | ||
|
||
it( 'should return shorthand value for gap if row and column are different', () => { | ||
const blockGapValue = { | ||
top: '88px', | ||
left: '88rem', | ||
}; | ||
expect( getGapCSSValue( blockGapValue ) ).toEqual( '88px 88rem' ); | ||
} ); | ||
|
||
it( 'should return default value if a top or left is missing', () => { | ||
const blockGapValue = { | ||
top: '88px', | ||
}; | ||
expect( getGapCSSValue( blockGapValue, '1px' ) ).toEqual( | ||
'88px 1px' | ||
); | ||
} ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters