-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Button Block]: Add padding block support (#31774)
* Add a utility for getting the spacing inline styles * Add padding support to the Button block
- Loading branch information
Showing
7 changed files
with
41 additions
and
0 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,28 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getInlineStyles } from './style'; | ||
|
||
// This utility is intended to assist where the serialization of the spacing | ||
// block support is being skipped for a block but the spacing related CSS | ||
// styles still need to be generated so they can be applied to inner elements. | ||
|
||
/** | ||
* Provides the CSS class names and inline styles for a block's spacing support | ||
* attributes. | ||
* | ||
* @param {Object} attributes Block attributes. | ||
* | ||
* @return {Object} Spacing block support derived CSS classes & styles. | ||
*/ | ||
export function getSpacingClassesAndStyles( attributes ) { | ||
const { style } = attributes; | ||
|
||
// Collect inline styles for spacing. | ||
const spacingStyles = style?.spacing || {}; | ||
const styleProp = getInlineStyles( { spacing: spacingStyles } ); | ||
|
||
return { | ||
style: styleProp, | ||
}; | ||
} |
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
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