Closed aitormendez closed 1 year ago
Might be more of a Q for the ACF folks https://github.com/AdvancedCustomFields/acf/issues/602#issuecomment-1027763520 I'm pretty sure they just pass these through to WP/Gutenberg, but maybe something else needs adding?
By the way, If it helps anyone I made a method to deal with block paddings.
/**
* Return padding styles.
*
* @return string
*/
public function paddingStyles()
{
if (property_exists($this->block, 'style') ) {
if (array_key_exists('padding', $this->block->style['spacing'])) {
$padding = $this->block->style['spacing']['padding'];
$styles = array_map(function($val) {
if (str_starts_with($val, 'var:preset|spacing|') ) {
return 'var(--wp--preset--spacing--' . substr($val, -2) . ')';
};
return $val; // return custom val if there is no preset
}, array_values($padding));
}
} else {
$styles = [
0 => '',
1 => '',
2 => '',
3 => '',
];
}
return $styles;
}
Then:
public function with()
{
return [
'padding' => $this->paddingStyles(),
];
}
And, in the view:
<div style="padding-top:{{ $padding[0] }};padding-right:{{ $padding[1] }};padding-bottom:{{ $padding[2] }};padding-left:{{ $padding[3] }}">
Closing
I've been trying some supports like spacing:
But only padding works. Why?
The same with typography:
Just font size is working.