Skip to content

Commit

Permalink
Address feedback and fix Group placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Mar 14, 2023
1 parent 8de907b commit 1652c62
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support
}
}
} elseif ( 'grid' === $layout_type ) {
$is_responsive = array_key_exists( 'isResponsive', $layout ) ? $layout['isResponsive'] : true;

if ( $layout['isResponsive'] ) {
if ( $is_responsive ) {
$minimum_column_width = ! empty( $layout['minimumColumnWidth'] ) ? $layout['minimumColumnWidth'] : '12rem';

$layout_styles[] = array(
Expand Down
3 changes: 2 additions & 1 deletion lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,8 @@ protected function get_layout_styles( $block_metadata ) {
$base_style_rules = _wp_array_get( $layout_definition, array( 'baseStyles' ), array() );

if (
! empty( $class_name )
! empty( $class_name ) &&
is_array( $base_style_rules )
) {
// Output display mode. This requires special handling as `display` is not exposed in `safe_style_css_filter`.
if (
Expand Down
9 changes: 8 additions & 1 deletion lib/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,14 @@
"slug": "grid",
"className": "is-layout-grid",
"displayMode": "grid",
"baseStyles": [],
"baseStyles": [
{
"selector": " > *",
"rules": {
"margin": "0"
}
}
],
"spacingStyles": [
{
"selector": "",
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/layouts/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function GridLayoutMinimumWidthControl( { layout, onChange } ) {
return (
<UnitControl
size={ '__unstable-large' }
label={ __( 'Minimum column width ' ) }
onChange={ ( value ) => {
onChange( {
...layout,
Expand Down
14 changes: 13 additions & 1 deletion packages/block-library/src/group/placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ const getGroupPlaceholderIcons = ( name = 'group' ) => {
<Path d="M42 0H2C.9 0 0 .9 0 2v12.5c0 .6.4 1 1 1h42c.6 0 1-.4 1-1V2c0-1.1-.9-2-2-2zm1 16.5H1c-.6 0-1 .4-1 1V30c0 1.1.9 2 2 2h40c1.1 0 2-.9 2-2V17.5c0-.6-.4-1-1-1z" />
</SVG>
),
'group-grid': (
<SVG
xmlns="http://www.w3.org/2000/svg"
width="44"
height="32"
viewBox="0 0 44 32"
>
<Path d="m20.30137,-0.00025l-18.9728,0c-0.86524,0.07234 -1.41711,0.79149 -1.41711,1.89149l0,12.64468c0,0.6 0.73401,0.96383 1.0304,0.96383l19.67469,0.03617c0.29639,0 1.0304,-0.4 1.0304,-1l-0.03576,-12.7532c0,-1.1 -0.76644,-1.78297 -1.30983,-1.78297zm0.52975,16.60851l-19.99654,-0.03617c-0.29639,0 -0.92312,0.36383 -0.92312,0.96383l-0.03576,12.68085c0,1.1 0.8022,1.81915 1.34559,1.81915l19.00857,0c0.54339,0 1.45287,-0.71915 1.45287,-1.81915l0,-12.53617c0,-0.6 -0.5552,-1.07234 -0.8516,-1.07234z" />
<Path d="m42.73056,-0.03617l-18.59217,0c-0.84788,0.07234 -1.38868,0.79149 -1.38868,1.89149l0,12.64468c0,0.6 0.71928,0.96383 1.00973,0.96383l19.27997,0.03617c0.29045,0 1.00973,-0.4 1.00973,-1l-0.03504,-12.7532c0,-1.1 -0.75106,-1.78297 -1.28355,-1.78297zm0.51912,16.60851l-19.59537,-0.03617c-0.29045,0 -0.9046,0.36383 -0.9046,0.96383l-0.03504,12.68085c0,1.1 0.78611,1.81915 1.31859,1.81915l18.62721,0c0.53249,0 1.42372,-0.71915 1.42372,-1.81915l0,-12.53617c0,-0.6 -0.54407,-1.07234 -0.83451,-1.07234z" />
</SVG>
),
};
return icons?.[ name ];
};
Expand Down Expand Up @@ -85,7 +96,8 @@ export function useShouldShowPlaceHolder( {
! fontSize &&
! textColor &&
! style &&
usedLayoutType !== 'flex'
usedLayoutType !== 'flex' &&
usedLayoutType !== 'grid'
);

useEffect( () => {
Expand Down

0 comments on commit 1652c62

Please sign in to comment.