Skip to content

Commit

Permalink
prep build 01/15
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Jan 15, 2024
2 parents 351b92d + a85fbc4 commit ce94d0c
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 49 deletions.
4 changes: 3 additions & 1 deletion docs/getting-started/quick-start-guide.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Quick Start Guide

This guide is designed to demonstrate the basic principles of block development in WordPress using a hands-on approach. Following the steps below, you will create a custom block plugin that uses modern JavaScript (ESNext and JSX) in a matter of minutes. The example block displays the copyright symbol (©) and the current year, the perfect addition to any website's footer.
This guide is designed to demonstrate the basic principles of block development in WordPress using a hands-on approach. Following the steps below, you will create a custom block plugin that uses modern JavaScript (ESNext and JSX) in a matter of minutes. The example block displays the copyright symbol (©) and the current year, the perfect addition to any website's footer. You can see these steps in action through this short video demonstration.

<div style="position:relative;overflow:hidden;padding-top:56.25%;"><iframe src="https://www.youtube.com/embed/nrut8SfXA44?si=YxvmHmAoYx-BDCog" title="WordPress Block Development: Quick Start Guide Video" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="true" style="position:absolute;top:0;left:0;width:100%;max-width:960px;height:100%;max-height:540px;"></iframe></div>

## Scaffold the block plugin

Expand Down
47 changes: 17 additions & 30 deletions docs/reference-guides/block-api/block-patterns.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
# Patterns

Block Patterns are predefined block layouts, available from the patterns tab of the block inserter. Once inserted into content, the blocks are ready for additional or modified content and configuration.

In this Document:
- [Patterns](#patterns)
- [Block Patterns](#block-patterns)
- [register_block_pattern](#register_block_pattern)
- [Unregistering Block Patterns](#unregistering-block-patterns)
- [unregister_block_pattern](#unregister_block_pattern)
- [Block Pattern Categories](#block-pattern-categories)
- [register_block_pattern_category](#register_block_pattern_category)
- [unregister_block_pattern_category](#unregister_block_pattern_category)
- [Block patterns contextual to block types and pattern transformations](#block-patterns-contextual-to-block-types-and-pattern-transformations)
- [Semantic block patterns](#semantic-block-patterns)
Block Patterns are predefined block layouts available from the patterns tab of the block inserter. Once inserted into content, the blocks are ready for additional or modified content and configuration.

## Block patterns

Expand All @@ -33,12 +21,12 @@ The properties available for block patterns are:
- `keywords` (optional): An array of aliases or keywords that help users discover the pattern while searching.
- `viewportWidth` (optional): An integer specifying the intended width of the pattern to allow for a scaled preview of the pattern in the inserter.
- `blockTypes` (optional): An array of block types that the pattern is intended to be used with. Each value needs to be the declared block's `name`.
- `postTypes` (optional): An array of post types that the pattern is restricted to be used with. The pattern will only be available when editing one of the post types passed on the array, for all the other post types the pattern is not available at all.
- `templateTypes` (optional): An array of template types where the pattern makes sense e.g: '404' if the pattern is for a 404 page, single-post if the pattern is for showing a single post.
- `postTypes` (optional): An array of post types that the pattern is restricted to be used with. The pattern will only be available when editing one of the post types passed on the array. For all the other post types, the pattern is not available at all.
- `templateTypes` (optional): An array of template types where the pattern makes sense, for example, `404` if the pattern is for a 404 page, `single-post` if the pattern is for showing a single post.
- `inserter` (optional): By default, all patterns will appear in the inserter. To hide a pattern so that it can only be inserted programmatically, set the `inserter` to `false`.
- `source` (optional): A string that denotes the source of the pattern. For a plugin registering a pattern, pass the string 'plugin'. For a theme, pass the string 'theme'.
- `source` (optional): A string that denotes the source of the pattern. For a plugin registering a pattern, pass the string `plugin`. For a theme, pass the string `theme`.

The following code sample registers a block pattern named 'my-plugin/my-awesome-pattern':
The following code sample registers a block pattern named `my-plugin/my-awesome-pattern`:

```php
register_block_pattern(
Expand All @@ -51,9 +39,7 @@ register_block_pattern(
);
```

_Note:_

`register_block_pattern()` should be called from a handler attached to the init hook.
Note that `register_block_pattern()` should be called from a handler attached to the `init` hook.

```php
function my_plugin_register_my_patterns() {
Expand All @@ -67,10 +53,11 @@ add_action( 'init', 'my_plugin_register_my_patterns' );

### unregister_block_pattern

The `unregister_block_pattern` helper function allows for a previously registered block pattern to be unregistered from a theme or plugin and receives one argument.
The `unregister_block_pattern` helper function allows a previously registered block pattern to be unregistered from a theme or plugin and receives one argument.

- `title`: The name of the block pattern to be unregistered.

The following code sample unregisters the block pattern named 'my-plugin/my-awesome-pattern':
The following code sample unregisters the block pattern named `my-plugin/my-awesome-pattern`:

```php
unregister_block_pattern( 'my-plugin/my-awesome-pattern' );
Expand All @@ -95,14 +82,15 @@ Block patterns can be grouped using categories. The block editor comes with bund
### register_block_pattern_category

The `register_block_pattern_category` helper function receives two arguments.

- `title`: A machine-readable title for the block pattern category.
- `properties`: An array describing properties of the pattern category.

The properties of the pattern categories include:

- `label` (required): A human-readable label for the pattern category.

The following code sample registers the category named 'hero':
The following code sample registers the category named `hero`:

```php
register_block_pattern_category(
Expand All @@ -127,12 +115,11 @@ add_action( 'init', 'my_plugin_register_my_pattern_categories' );

### unregister_block_pattern_category

`unregister_block_pattern_category` allows unregistering a pattern category.

The `unregister_block_pattern_category` helper function allows for a previously registered block pattern category to be unregistered from a theme or plugin and receives one argument.

- `title`: The name of the block pattern category to be unregistered.

The following code sample unregisters the category named 'hero':
The following code sample unregisters the category named `hero`:

```php
unregister_block_pattern_category( 'hero' );
Expand All @@ -154,7 +141,7 @@ add_action( 'init', 'my_plugin_unregister_my_pattern_categories' );

It is possible to attach a block pattern to one or more block types. This adds the block pattern as an available transform for that block type.

Currently these transformations are available only to simple blocks (blocks without inner blocks). In order for a pattern to be suggested, **every selected block must be present in the block pattern**.
Currently, these transformations are available only to simple blocks (blocks without inner blocks). In order for a pattern to be suggested, **every selected block must be present in the block pattern**.

For instance:

Expand All @@ -171,9 +158,9 @@ register_block_pattern(
);
```

The above code registers a block pattern named 'my-plugin/powered-by-wordpress' and also shows the pattern in the "transform menu" of paragraph blocks. The transformation result will be keeping the paragraph's existing content and also apply the other attributes - in this case the background and text color.
The above code registers a block pattern named `my-plugin/powered-by-wordpress` and shows the pattern in the "transform menu" of paragraph blocks. The transformation result will keep the paragraph's existing content and apply the other attributes - in this case, the background and text color.

As mentioned above pattern transformations for simple blocks can also work if we have selected multiple blocks and there are matching contextual patterns to these blocks. Let's see an example of a pattern where two block types are attached.
As mentioned above, pattern transformations for simple blocks can also work if we have selected multiple blocks and there are matching contextual patterns to these blocks. Let's see an example of a pattern where two block types are attached.

```php
register_block_pattern(
Expand All @@ -194,7 +181,7 @@ register_block_pattern(
);
```

In the above example if we select **one of the two** block types, either a paragraph or a heading block, this pattern will be suggested by transforming the selected block using its content and will also add the remaining blocks from the pattern. If on the other hand we multi select one paragraph and one heading block, both blocks will be transformed.
In the above example, if we select **one of the two** block types, either a paragraph or a heading block, this pattern will be suggested by transforming the selected block using its content and will also add the remaining blocks from the pattern. If, on the other hand, we multi-select one paragraph and one heading block, both blocks will be transformed.

Blocks can also use these contextual block patterns in other places. For instance, when inserting a new Query Loop block, the user is provided with a list of all patterns attached to the block.

Expand Down
11 changes: 10 additions & 1 deletion packages/dataviews/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,16 @@
padding-left: $grid-unit-05;
}
}

tbody {
td {
vertical-align: top;
}
.dataviews-view-table__cell-content-wrapper {
min-height: $grid-unit-40;
display: flex;
align-items: center;
}
}
.dataviews-view-table-header-button {
padding: $grid-unit-05 $grid-unit-10;
font-size: 11px;
Expand Down
34 changes: 20 additions & 14 deletions packages/dataviews/src/view-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,17 +536,21 @@ function ViewTable( {
minWidth: 20,
} }
>
<SingleSelectionCheckbox
id={ getItemId( item ) || index }
item={ item }
selection={ selection }
onSelectionChange={
onSelectionChange
}
getItemId={ getItemId }
data={ data }
primaryField={ primaryField }
/>
<span className="dataviews-view-table__cell-content-wrapper">
<SingleSelectionCheckbox
id={
getItemId( item ) || index
}
item={ item }
selection={ selection }
onSelectionChange={
onSelectionChange
}
getItemId={ getItemId }
data={ data }
primaryField={ primaryField }
/>
</span>
</td>
) }
{ visibleFields.map( ( field ) => (
Expand All @@ -560,9 +564,11 @@ function ViewTable( {
field.maxWidth || undefined,
} }
>
{ field.render( {
item,
} ) }
<span className="dataviews-view-table__cell-content-wrapper">
{ field.render( {
item,
} ) }
</span>
</td>
) ) }
{ !! actions?.length && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,13 @@ function FontLibraryProvider( { children } ) {
'settings.typography.fontFamilies',
] );
refreshLibrary();
setIsInstalling( false );

return response;
} catch ( error ) {
setIsInstalling( false );
return {
errors: [ error ],
};
} finally {
setIsInstalling( false );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function InstalledFonts() {
!! libraryFontSelected && libraryFontSelected?.source !== 'theme';

useEffect( () => {
handleSelectFont( libraryFontSelected );
refreshLibrary();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [] );
Expand Down

0 comments on commit ce94d0c

Please sign in to comment.