Skip to content

Commit 09b4cf2

Browse files
Merge branch 'WordPress:trunk' into trunk
2 parents 6ed9ff3 + 94df941 commit 09b4cf2

File tree

6 files changed

+319
-119
lines changed

6 files changed

+319
-119
lines changed

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

+97-4
Original file line numberDiff line numberDiff line change
@@ -1053,16 +1053,16 @@ Pseudo selectors `:hover`, `:focus`, `:visited`, `:active`, `:link`, `:any-link`
10531053

10541054
#### Variations
10551055

1056-
A block can have a "style variation", as defined per the [block.json specification](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/#styles-optional). Theme authors can define the style attributes for an existing style variation using the theme.json file. Styles for unregistered style variations will be ignored.
1056+
A block can have a "style variation," as defined in the [block.json specification](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/#styles-optional). Theme authors can define the style attributes for an existing style variation using the `theme.json` file. Styles for unregistered style variations will be ignored.
10571057

1058-
Note that variations are a "block concept", they only exist bound to blocks. The `theme.json` specification respects that distinction by only allowing `variations` at the block-level but not at the top-level. It's also worth highlighting that only variations defined in the `block.json` file of the block are considered "registered": so far, the style variations added via `register_block_style` or in the client are ignored, see [this issue](https://github.com/WordPress/gutenberg/issues/49602) for more information.
1058+
Note that variations are a "block concept"they only exist when bound to blocks. The `theme.json` specification respects this distinction by only allowing `variations` at the block level, not the top level. Its also worth highlighting that only variations defined in the `block.json` file of the block or via `register_block_style` on the server are considered "registered" for `theme.json` styling purposes.
10591059

10601060
For example, this is how to provide styles for the existing `plain` variation for the `core/quote` block:
10611061

10621062
```json
10631063
{
10641064
"version": 3,
1065-
"styles":{
1065+
"styles": {
10661066
"blocks": {
10671067
"core/quote": {
10681068
"variations": {
@@ -1078,14 +1078,107 @@ For example, this is how to provide styles for the existing `plain` variation fo
10781078
}
10791079
```
10801080

1081-
The resulting CSS output is this:
1081+
The resulting CSS output is:
10821082

10831083
```css
10841084
.wp-block-quote.is-style-plain {
10851085
background-color: red;
10861086
}
10871087
```
10881088

1089+
It is also possible for multiple block types to share the same variation styles. There are two recommended ways to define such shared styles:
1090+
1091+
1. `theme.json` partial files
1092+
2. programmatically, using `register_block_style`
1093+
1094+
##### Variation Theme.json Partials
1095+
1096+
Like theme style variation partials, those for block style variations reside within a theme's `/styles` directory. However, they are differentiated from theme style variations by the introduction of a top-level property called `blockTypes`. The `blockTypes` property is an array of block types for which the block style variation has been registered.
1097+
1098+
Additionally, a `slug` property is available to provide consistency between the different sources that may define block style variations and to decouple the `slug` from the translatable `title` property.
1099+
1100+
The following is an example of a `theme.json` partial that defines styles for the "Variation A" block style for the Group, Columns, and Media & Text block types:
1101+
1102+
```json
1103+
{
1104+
"$schema": "https://schemas.wp.org/trunk/theme.json",
1105+
"version": 3,
1106+
"title": "Variation A",
1107+
"slug": "variation-a",
1108+
"blockTypes": [ "core/group", "core/columns", "core/media-text" ],
1109+
"styles": {
1110+
"color": {
1111+
"background": "#eed8d3",
1112+
"text": "#201819"
1113+
},
1114+
"elements": {
1115+
"heading": {
1116+
"color": {
1117+
"text": "#201819"
1118+
}
1119+
}
1120+
},
1121+
"blocks": {
1122+
"core/group": {
1123+
"color": {
1124+
"background": "#825f58",
1125+
"text": "#eed8d3"
1126+
},
1127+
"elements": {
1128+
"heading": {
1129+
"color": {
1130+
"text": "#eed8d3"
1131+
}
1132+
}
1133+
}
1134+
}
1135+
}
1136+
}
1137+
}
1138+
```
1139+
1140+
##### Programmatically Registering Variation Styles
1141+
1142+
As an alternative to `theme.json` partials, you can register variation styles at the same time as registering the variation itself through `register_block_style`. This is done by registering the block style for an array of block types while also passing a "style object" within the `style_data` option.
1143+
1144+
The example below registers a "Green" variation for the Group and Columns blocks. Note that the style object passed via `style_data` follows the same shape as the `styles` property of a `theme.json` partial.
1145+
1146+
```php
1147+
register_block_style(
1148+
array( 'core/group', 'core/columns' ),
1149+
array(
1150+
'name' => 'green',
1151+
'label' => __( 'Green' ),
1152+
'style_data' => array(
1153+
'color' => array(
1154+
'background' => '#4f6f52',
1155+
'text' => '#d2e3c8',
1156+
),
1157+
'blocks' => array(
1158+
'core/group' => array(
1159+
'color' => array(
1160+
'background' => '#739072',
1161+
'text' => '#e3eedd',
1162+
),
1163+
),
1164+
),
1165+
'elements' => array(
1166+
'link' => array(
1167+
'color' => array(
1168+
'text' => '#ead196',
1169+
),
1170+
':hover' => array(
1171+
'color' => array(
1172+
'text' => '#ebd9b4',
1173+
),
1174+
),
1175+
),
1176+
),
1177+
),
1178+
)
1179+
);
1180+
```
1181+
10891182
### customTemplates
10901183

10911184
<div class="callout callout-alert">Supported in WordPress from version 5.9.</div>

packages/block-editor/src/components/inserter/category-tabs/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ function CategoryTabs( {
6464
<Tabs.Tab
6565
key={ category.name }
6666
tabId={ category.name }
67-
aria-label={ category.label }
6867
aria-current={
6968
category === selectedCategory ? 'true' : undefined
7069
}

packages/block-editor/src/components/text-transform-control/README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# TextTransformControl
22

33
The `TextTransformControl` component is responsible for rendering a control element that allows users to select and apply text transformation options to blocks or elements in the Gutenberg editor. It provides an intuitive interface for changing the text appearance by applying different transformations such as `none`, `uppercase`, `lowercase`, `capitalize`.
4-
4+
55
![TextTransformConrol Element in Inspector Control](https://raw.githubusercontent.com/WordPress/gutenberg/HEAD/docs/assets/text-transform-component.png?raw=true)
66

77
## Development guidelines
@@ -28,7 +28,6 @@ const MyTextTransformControlComponent = () => (
2828
### `value`
2929

3030
- **Type:** `String`
31-
- **Default:** `none`
3231
- **Options:** `none`, `uppercase`, `lowercase`, `capitalize`
3332

3433
The current value of the Text Transform setting. You may only choose from the `Options` listed above.
@@ -37,4 +36,4 @@ The current value of the Text Transform setting. You may only choose from the `O
3736

3837
- **Type:** `Function`
3938

40-
A callback function invoked when the Text Transform value is changed via an interaction with any of the buttons. Called with the Text Transform value (`none`, `uppercase`, `lowercase`, `capitalize`) as the only argument.
39+
A callback function invoked when the Text Transform value is changed via an interaction with any of the buttons. Called with the Text Transform value (`none`, `uppercase`, `lowercase`, `capitalize`) as the only argument.

packages/block-editor/src/components/text-transform-control/stories/index.story.js

+53-16
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,63 @@ import { useState } from '@wordpress/element';
88
*/
99
import TextTransformControl from '../';
1010

11-
export default {
11+
const meta = {
1212
title: 'BlockEditor/TextTransformControl',
1313
component: TextTransformControl,
14+
parameters: {
15+
docs: {
16+
canvas: { sourceState: 'shown' },
17+
description: {
18+
component:
19+
'Control to facilitate text transformation selections.',
20+
},
21+
},
22+
},
1423
argTypes: {
15-
onChange: { action: 'onChange' },
24+
onChange: {
25+
action: 'onChange',
26+
control: {
27+
type: null,
28+
},
29+
description: 'Handles change in text transform selection.',
30+
table: {
31+
type: {
32+
summary: 'function',
33+
},
34+
},
35+
},
36+
className: {
37+
control: { type: 'text' },
38+
description: 'Class name to add to the control.',
39+
table: {
40+
type: { summary: 'string' },
41+
},
42+
},
43+
value: {
44+
control: { type: null },
45+
description: 'Currently selected text transform.',
46+
table: {
47+
type: { summary: 'string' },
48+
},
49+
},
1650
},
1751
};
1852

19-
const Template = ( { onChange, ...args } ) => {
20-
const [ value, setValue ] = useState();
21-
return (
22-
<TextTransformControl
23-
{ ...args }
24-
onChange={ ( ...changeArgs ) => {
25-
onChange( ...changeArgs );
26-
setValue( ...changeArgs );
27-
} }
28-
value={ value }
29-
/>
30-
);
31-
};
53+
export default meta;
54+
55+
export const Default = {
56+
render: function Template( { onChange, ...args } ) {
57+
const [ value, setValue ] = useState();
3258

33-
export const Default = Template.bind( {} );
59+
return (
60+
<TextTransformControl
61+
{ ...args }
62+
onChange={ ( ...changeArgs ) => {
63+
onChange( ...changeArgs );
64+
setValue( ...changeArgs );
65+
} }
66+
value={ value }
67+
/>
68+
);
69+
},
70+
};

packages/block-library/src/query-total/index.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ function render_block_core_query_total( $attributes, $content, $block ) {
4343
$range_text = sprintf(
4444
/* translators: 1: Start index of posts, 2: Total number of posts */
4545
__( 'Displaying %1$s of %2$s' ),
46-
'<strong>' . $start . '</strong>',
47-
'<strong>' . $max_rows . '</strong>'
46+
$start,
47+
$max_rows
4848
);
4949
} else {
5050
$range_text = sprintf(
5151
/* translators: 1: Start index of posts, 2: End index of posts, 3: Total number of posts */
5252
__( 'Displaying %1$s – %2$s of %3$s' ),
53-
'<strong>' . $start . '</strong>',
54-
'<strong>' . $end . '</strong>',
55-
'<strong>' . $max_rows . '</strong>'
53+
$start,
54+
$end,
55+
$max_rows
5656
);
5757
}
5858

@@ -61,10 +61,11 @@ function render_block_core_query_total( $attributes, $content, $block ) {
6161

6262
case 'total-results':
6363
default:
64-
$output = sprintf(
65-
'<p><strong>%d</strong> %s</p>',
66-
$max_rows,
67-
_n( 'result found', 'results found', $max_rows )
64+
// translators: %d: number of results.
65+
$total_text = sprintf( _n( '%d result found', '%d results found', $max_rows ), $max_rows );
66+
$output = sprintf(
67+
'<p>%s</p>',
68+
$total_text
6869
);
6970
break;
7071
}

0 commit comments

Comments
 (0)