-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add the 'Block Settings' panel #43
Conversation
Using Rob's HTML and CSS, begin this panel and add a component test for it.
The PHPUnit test jobs failed with a message that the GD extension is not available.
From doing: composer install --dev ext-gd
For now at least, enqueue the 'wp-components' stylesheet. Eventually, it'd be good to import it from node_modules, so we know exactly what version is used. https://github.com/WordPress/gutenberg/blob/f152a28c5331d56230b716ee8b948b9a56590929/packages/components/README.md
On adding a new category, display it in the <select>.
Maybe refactor getFullBlock() into a helper function.
So two hooks can use this.
This will make it easier to use them in the 'Edit Block' UI.
@@ -0,0 +1,25 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these files in common/icons/
are just ported from assets/icons.json
. There's no intended change.
This is working, but it needs a lot of styling, some of which can be ported over.
Icon UIHi @RobStino and @lukecarbis, The new UI mainly looks like that, I just need to add styling. I think the previous UI is good 😄 |
They use contexts, so they don't need to be as JSX in the same component.
I had used something a little different, making the <button> lower in the tree.
Using Tailwind utility classes, instead of custom classes.
Add a unit test for snakeCaseToPascalCase()
The icons will only be available via JavaScript.
return ( | ||
<> | ||
<GcbInspector blockProps={ blockProps } block={ block } /> | ||
<div className={ className } key={ `form-controls-${ block.name }` } > | ||
{ isSelected ? ( | ||
<div className="block-form"> | ||
<h3 dangerouslySetInnerHTML={ { __html: icons[ block.icon ] + ' ' + block.title } } /> | ||
<FormControls blockProps={ blockProps } block={ block } /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<FormControls>
was just a wrapper for <Fields>
, so this simply uses <Fields>
*/ | ||
const Fields = ( { fields, parentBlock, parentBlockProps, rowIndex } ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff is mainly from indenting one level more, there's very little changed.
if ( ! fullBlock[ blockNameWithNamespace ].fields ) { | ||
fullBlock[ blockNameWithNamespace ].fields = []; | ||
} | ||
const { controls, field, changeControl, changeFieldSetting } = useField(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These deletions are mainly moved to the useField
hook.
This will be true initially, so it should be easier to grasp.
js/src/edit-block/components/side.js
Outdated
{ __( 'Field', 'genesis-custom-blocks' ) } | ||
</button> | ||
</div> | ||
<FieldPanel /> | ||
{ displayFieldPanel ? <FieldPanel /> : <BlockPanel /> } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ __( 'Field', 'genesis-custom-blocks' ) } | ||
</button> | ||
</div> | ||
<FieldPanel /> | ||
{ displayBlockPanel ? <BlockPanel /> : <FieldPanel /> } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | ||
* @param array $icons The available icons. | ||
*/ | ||
return apply_filters( 'genesis_custom_blocks_icons', $icons ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo: update the documentation for this removed filter when this is released.
These are the post types where the block will display.
It is actually a slug, so this is more semantic.
display: block; | ||
margin-top: 0.5rem; | ||
.components-form-token-field__label { | ||
font-size: .875rem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from Gutenberg, for the 'Keywords' section
@@ -1,121 +0,0 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*/ | ||
const FormControls = ( { blockProps, block } ) => { | ||
return ( | ||
<Fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is deleted because it's not really needed, it's just a wrapper for <Fields>
They all have the same markup in <svg>, so no need to copy it every time.
@@ -402,7 +402,7 @@ public function save_draft_button() { | |||
public function render_properties_meta_box() { | |||
$post = get_post(); | |||
$block = new Block( $post->ID ); | |||
$icons = genesis_custom_blocks()->get_icons(); | |||
$icons = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this file will be deleted when this editor redesign is done. It mainly renders the editor and handles its data.
From doing npm run lint:js:fix
Hi @johnstonphilip, @BMO-tech, and @mikemcalister, Most of the 173 changed files are The main scope of this is the Block Settings panel. No hurry reviewing this, it's Friday 🤣 Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected: you can edit, undo, and save the 'Slug', 'Icon', 'Category', and 'Keywords', and 'Post Types':
This is all working perfectly for me.
Nice, thanks so much for testing this! |
Changes
Testing instructions
composer install && npm ci && npm run dev
wp post create --post_type='genesis_custom_block' --post_title='Test UI' --post_excerpt='' --post_content='{"genesis-custom-blocks\/test-ui":{"name":"test-ui","title":"Test UI","excluded":[],"icon":"genesis_custom_blocks","category":{"slug":"common","title":"Common Blocks","icon":null},"keywords":["baz"],"fields":{"text":{"name":"text","label":"Text","control":"text","type":"string","order":0,"location":"editor","width":"100","help":"","default":"","placeholder":"","maxlength":null}}}}'
It should say something like
Success! Created post 8
Go to the URL for that post: https://your-wp-local/wp-admin/post.php?post=8&action=edit
Expected: It should initially look like this:
Expected: you can edit, undo, and save the 'Slug', 'Icon', 'Category', and 'Keywords', and 'Post Types':
The scope of this PR is mainly the 'Block Settings' panel. There is still a lot of work needed in the editor.