Skip to content

Commit d701f12

Browse files
aaronrobertshawtellthemachinesramonjd
authored
Block Supports: Add min width support to dimensions (#76949)
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
1 parent 7d5ea54 commit d701f12

29 files changed

Lines changed: 310 additions & 97 deletions

File tree

backport-changelog/7.1/11465.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
https://github.com/WordPress/wordpress-develop/pull/11465
2+
3+
* https://github.com/WordPress/gutenberg/pull/76949

docs/how-to-guides/themes/global-settings-and-styles.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ The settings section has the following structure:
239239
"aspectRatio": false,
240240
"height": false,
241241
"minHeight": false,
242+
"minWidth": false,
242243
"width": false,
243244
},
244245
"layout": {
@@ -304,7 +305,7 @@ There's one special setting property, `appearanceTools`, which is a boolean and
304305
- background: backgroundImage, backgroundSize
305306
- border: color, radius, style, width
306307
- color: link
307-
- dimensions: aspectRatio, height, minHeight, width
308+
- dimensions: aspectRatio, height, minHeight, minWidth, width
308309
- position: sticky
309310
- spacing: blockGap, margin, padding
310311
- typography: lineHeight
@@ -776,6 +777,7 @@ Each block declares which style properties it exposes via the [block supports me
776777
"aspectRatio": "value",
777778
"height": "value"
778779
"minHeight": "value"
780+
"minWidth": "value"
779781
"width": "value"
780782
},
781783
"filter": {

docs/how-to-guides/themes/theme-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ Use this setting to enable the following Global Styles settings:
475475
- color: link
476476
- spacing: blockGap, margin, padding
477477
- typography: lineHeight
478-
- dimensions: aspectRatio, height, minHeight, width
478+
- dimensions: aspectRatio, height, minHeight, minWidth, width
479479
- position: sticky
480480

481481
```php

docs/reference-guides/block-api/block-supports.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ _**Note:** Since WordPress 6.2._
646646
- Subproperties:
647647
- `height`: type `boolean`, default value `false`
648648
- `minHeight`: type `boolean`, default value `false`
649+
- `minWidth`: type `boolean`, default value `false`
649650
- `width`: type `boolean`, default value `false`
650651
651652
This value signals that a block supports some of the CSS style properties related to dimensions. When it does, the block editor will show UI controls for the user to set their values if [the theme declares support](/docs/how-to-guides/themes/global-settings-and-styles.md#opt-in-into-ui-controls).
@@ -656,14 +657,15 @@ supports: {
656657
aspectRatio: true // Enable aspect ratio control.
657658
height: true // Enable height control.
658659
minHeight: true // Enable min height control.
660+
minWidth: true // Enable min width control.
659661
width: true // Enable width control.
660662
}
661663
}
662664
```
663665
664666
When a block declares support for a specific dimensions property, its attributes definition is extended to include the `style` attribute.
665667
666-
- `style`: an attribute of `object` type with no default assigned. This is added when `aspectRatio`, `height`, `minHeight`, or `width` support is declared. It stores the custom values set by the user. For example:
668+
- `style`: an attribute of `object` type with no default assigned. This is added when `aspectRatio`, `height`, `minHeight`, `minWidth`, or `width` support is declared. It stores the custom values set by the user. For example:
667669
668670
```js
669671
attributes: {
@@ -672,6 +674,7 @@ attributes: {
672674
aspectRatio: "16/9",
673675
height: "40vh",
674676
minHeight: "50vh",
677+
minWidth: "200px",
675678
width: "400px",
676679
}
677680
}

docs/reference-guides/core-blocks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ Gather blocks in a layout container. ([Source](https://github.com/WordPress/gute
398398

399399
- **Name:** core/group
400400
- **Category:** design
401-
- **Supports:** align (full, wide), allowedBlocks, anchor, ariaLabel, background (backgroundImage, backgroundSize, gradient), color (background, button, gradients, heading, link, text), dimensions (minHeight), interactivity (clientNavigation), layout (allowSizingOnChildren), position (sticky), shadow, spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~
401+
- **Supports:** align (full, wide), allowedBlocks, anchor, ariaLabel, background (backgroundImage, backgroundSize, gradient), color (background, button, gradients, heading, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), layout (allowSizingOnChildren), position (sticky), shadow, spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~
402402
- **Attributes:** tagName, templateLock
403403

404404
## Heading

docs/reference-guides/theme-json-reference/styles-versions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ New styles options are integrated into theme.json on a regular basis. Knowing th
5050
| `spacing.blockGap` | 5.9 | 5.9 |
5151
| `dimensions.height` | 7.0 | N/A |
5252
| `dimensions.minHeight` | 6.2 | N/A |
53+
| `dimensions.minWidth` | 7.1 | 7.1 |
5354
| `dimensions.width` | 7.0 | N/A |
5455
| `outline.color` | 6.2 | N/A |
5556
| `outline.offset` | 6.2 | N/A |

docs/reference-guides/theme-json-reference/theme-json-living.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Setting that enables the following UI tools:
4646
- background: backgroundImage, backgroundSize
4747
- border: color, radius, style, width
4848
- color: link, heading, button, caption
49-
- dimensions: aspectRatio, height, minHeight, width
49+
- dimensions: aspectRatio, height, minHeight, minWidth, width
5050
- position: sticky
5151
- spacing: blockGap, margin, padding
5252
- typography: lineHeight
@@ -114,6 +114,7 @@ Settings related to dimensions.
114114
| aspectRatios | Allow users to define aspect ratios for some blocks. | `[ { name, slug, ratio } ]` | |
115115
| height | Allow users to set custom height. | `boolean` | `false` |
116116
| minHeight | Allow users to set custom minimum height. | `boolean` | `false` |
117+
| minWidth | Allow users to set custom minimum width. | `boolean` | `false` |
117118
| width | Allow users to set custom width. | `boolean` | `false` |
118119
| dimensionSizes | Dimension size presets for dimension block supports. | `[ { name, slug, size } ]` | |
119120

@@ -274,6 +275,7 @@ Dimensions styles.
274275
| aspectRatio | Sets the `aspect-ratio` CSS property. | `string`, `{ ref }` |
275276
| height | Sets the `height` CSS property. | `string`, `{ ref }` |
276277
| minHeight | Sets the `min-height` CSS property. | `string`, `{ ref }` |
278+
| minWidth | Sets the `min-width` CSS property. | `string`, `{ ref }` |
277279
| width | Sets the `width` CSS property. | `string`, `{ ref }` |
278280

279281
---

lib/block-supports/dimensions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function gutenberg_apply_dimensions_support( $block_type, $block_attributes ) {
5757
}
5858

5959
$dimensions_block_styles = array();
60-
$supported_features = array( 'minHeight', 'height', 'width' );
60+
$supported_features = array( 'minHeight', 'minWidth', 'height', 'width' );
6161

6262
foreach ( $supported_features as $feature ) {
6363
$has_support = block_has_support( $block_type, array( 'dimensions', $feature ), false );

lib/class-wp-theme-json-gutenberg.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ class WP_Theme_JSON_Gutenberg {
290290
'margin-bottom' => array( 'spacing', 'margin', 'bottom' ),
291291
'margin-left' => array( 'spacing', 'margin', 'left' ),
292292
'min-height' => array( 'dimensions', 'minHeight' ),
293+
'min-width' => array( 'dimensions', 'minWidth' ),
293294
'outline-color' => array( 'outline', 'color' ),
294295
'outline-offset' => array( 'outline', 'offset' ),
295296
'outline-style' => array( 'outline', 'style' ),
@@ -432,6 +433,7 @@ class WP_Theme_JSON_Gutenberg {
432433
'dimensionSizes' => null,
433434
'height' => null,
434435
'minHeight' => null,
436+
'minWidth' => null,
435437
'width' => null,
436438
),
437439
'layout' => array(
@@ -552,6 +554,7 @@ class WP_Theme_JSON_Gutenberg {
552554
'aspectRatio' => null,
553555
'height' => null,
554556
'minHeight' => null,
557+
'minWidth' => null,
555558
'width' => null,
556559
),
557560
'filter' => array(
@@ -797,6 +800,7 @@ public static function get_element_class_name( $element ) {
797800
array( 'dimensions', 'aspectRatio' ),
798801
array( 'dimensions', 'height' ),
799802
array( 'dimensions', 'minHeight' ),
803+
array( 'dimensions', 'minWidth' ),
800804
array( 'dimensions', 'width' ),
801805
// BEGIN EXPERIMENTAL.
802806
// Allow `position.fixed` to be opted-in by default.

0 commit comments

Comments
 (0)