Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group: Update block example #63114

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 26 additions & 29 deletions packages/block-library/src/group/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,56 +22,53 @@ export { metadata, name };
export const settings = {
icon,
example: {
innerBlocks: [
{
name: 'core/paragraph',
attributes: {
customTextColor: '#cf2e2e',
fontSize: 'large',
content: __( 'One.' ),
},
attributes: {
layout: {
type: 'constrained',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple and looking pretty good.

2024-07-04.19.10.21.mp4

justifyContent: 'center',
},
{
name: 'core/paragraph',
attributes: {
customTextColor: '#ff6900',
fontSize: 'large',
content: __( 'Two.' ),
style: {
spacing: {
padding: {
top: '4em',
right: '3em',
bottom: '4em',
left: '3em',
},
},
},
},
innerBlocks: [
{
name: 'core/paragraph',
name: 'core/heading',
attributes: {
customTextColor: '#fcb900',
fontSize: 'large',
content: __( 'Three.' ),
content: __( 'La Mancha' ),
textAlign: 'center',
},
},
{
name: 'core/paragraph',
attributes: {
customTextColor: '#00d084',
fontSize: 'large',
content: __( 'Four.' ),
align: 'center',
content: __(
'In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.'
),
},
},
{
name: 'core/paragraph',
name: 'core/spacer',
attributes: {
customTextColor: '#0693e3',
fontSize: 'large',
content: __( 'Five.' ),
height: '10px',
},
},
{
name: 'core/paragraph',
name: 'core/button',
attributes: {
customTextColor: '#9b51e0',
fontSize: 'large',
content: __( 'Six.' ),
text: __( 'Read more' ),
},
},
],
viewportWidth: 600,
},
transforms,
edit,
Expand Down
56 changes: 56 additions & 0 deletions packages/block-library/src/group/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,59 @@
import { __, _x } from '@wordpress/i18n';
import { group, row, stack, grid } from '@wordpress/icons';

const example = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this example being used at all?

I have a row block here and it's using the current index.js example. Stack and grid are the same.

CleanShot 2024-07-07 at 12 07 17

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used for previewing the different block variations in the block inserter.

Steps 5 - 8 in the test instructions cover this aspect. To save you having to fire up the PR locally you can see the original example with the main block inserter from the 30s mark on in the description's demo video.

Copy link
Contributor Author

@aaronrobertshaw aaronrobertshaw Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be easier still 🙂

Screen.Recording.2024-07-29.at.5.10.47.PM.mp4

innerBlocks: [
{
name: 'core/paragraph',
attributes: {
customTextColor: '#cf2e2e',
fontSize: 'large',
content: __( 'One.' ),
},
},
{
name: 'core/paragraph',
attributes: {
customTextColor: '#ff6900',
fontSize: 'large',
content: __( 'Two.' ),
},
},
{
name: 'core/paragraph',
attributes: {
customTextColor: '#fcb900',
fontSize: 'large',
content: __( 'Three.' ),
},
},
{
name: 'core/paragraph',
attributes: {
customTextColor: '#00d084',
fontSize: 'large',
content: __( 'Four.' ),
},
},
{
name: 'core/paragraph',
attributes: {
customTextColor: '#0693e3',
fontSize: 'large',
content: __( 'Five.' ),
},
},
{
name: 'core/paragraph',
attributes: {
customTextColor: '#9b51e0',
fontSize: 'large',
content: __( 'Six.' ),
},
},
],
};

const variations = [
{
name: 'group',
Expand All @@ -30,6 +83,7 @@ const variations = [
( ! blockAttributes.layout?.orientation ||
blockAttributes.layout?.orientation === 'horizontal' ),
icon: row,
example,
},
{
name: 'group-stack',
Expand All @@ -41,6 +95,7 @@ const variations = [
blockAttributes.layout?.type === 'flex' &&
blockAttributes.layout?.orientation === 'vertical',
icon: stack,
example,
},
{
name: 'group-grid',
Expand All @@ -51,6 +106,7 @@ const variations = [
isActive: ( blockAttributes ) =>
blockAttributes.layout?.type === 'grid',
icon: grid,
example,
},
];

Expand Down
Loading