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

Site Editor: Add Comment Avatar Core Block #35396

Merged
merged 24 commits into from
Oct 27, 2021

Conversation

cbravobernal
Copy link
Contributor

@cbravobernal cbravobernal commented Oct 6, 2021

This is the follow-up of a previous PR that was not following the workflow standards.

Replaces #35180.
Closes #30575.

More info on issue #30575.

Description

We are creating a new Comment Avatar Block. The user will be able to adjust the size, border-radius and padding of the Avatar component of all comments on its site by using the FSE template editor.

This component will be loaded by the parent component Query Loop Block, as part of the Comment Template. We have also more information on this tracking issue.

Loom of the last iteration:
https://www.loom.com/share/60f7c06c6acc4a5995f07beab75b359d

How has this been tested?

WordPress Version: 5.8.1

Gutenberg Version: 11.6.0-rc.1

Database: MySQL 8.0.16

Web Server: nginx

PHP Version: 7.3.5

Screenshots

Types of changes

Type Experimental
New feature Site Editor
Needs Accessibility Feedback (Although I tried with both keyboard and voice over and seems to be fine)
Needs Testing

Checklist:

  • My code is [manually] tested. Created a fixture. Is there any more automated test to do?
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 6, 2021
@github-actions
Copy link

github-actions bot commented Oct 6, 2021

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @c4rl0sbr4v0! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@getdave getdave added [Package] Block library /packages/block-library New Block Suggestion for a new block labels Oct 6, 2021
@cbravobernal cbravobernal changed the title Add/ Comment Avatar Core Block [WIP] Site Editor: Add Comment Avatar Core Block Oct 6, 2021
@gziolo gziolo requested a review from ntsekouras October 7, 2021 08:50
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Nice work. I left some minor comments related to the code.

You will have to add test fixtures for the new block as noted in the failing unit test:

Screen Shot 2021-10-07 at 11 09 45

You can find more details at https://github.com/WordPress/gutenberg/tree/trunk/test/integration/fixtures/blocks#readme.

lib/blocks.php Outdated Show resolved Hide resolved
packages/block-library/src/comment-avatar/index.php Outdated Show resolved Hide resolved
packages/block-library/src/comment-avatar/index.php Outdated Show resolved Hide resolved
@cbravobernal cbravobernal marked this pull request as ready for review October 8, 2021 11:21
@cbravobernal cbravobernal changed the title [WIP] Site Editor: Add Comment Avatar Core Block Site Editor: Add Comment Avatar Core Block Oct 8, 2021
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

It looks like the only remaining decision is to settle on how we handle avatar sizes.

The other concern is how to deal with backward compatibility challenges related to the fact that get_avatar function uses hooks internally. The HTML code in the editor might differ with what PHP outputs.

packages/block-library/src/comment-avatar/block.json Outdated Show resolved Hide resolved
packages/block-library/src/comment-avatar/edit.js Outdated Show resolved Hide resolved
@jameskoster
Copy link
Contributor

Looking great. A couple of thoughts on this one:

Since we have padding and radius, should we also include a background color option, and border controls? These seem to go hand in hand and will give themers the flexibility to create really interesting styles.

The name feels a little awkward, should it be "Comment Author Avatar" or "Commenter Avatar"? 🤔

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

When testing with Safari (macOS), something doesn't work as expected for the block. After I insert the block and move focus to another block (or refresh the page), I'm no longer able to edit the block.

Screen.Recording.2021-10-18.at.17.05.30.mov

commentId
);
const containerRef = useRef();
const clientWidth = useClientWidth( containerRef );
Copy link
Member

Choose a reason for hiding this comment

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

Does this value depend on the size of the screen? Won't it change when you resize the size of the browser?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it changes while I resize the browser:

Screen Shot 2021-10-18 at 16 51 41

Screen Shot 2021-10-18 at 16 52 00

Screen Shot 2021-10-18 at 16 52 36

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 taking the max width of the container. Should we put instead a fixed value?

Copy link
Member

Choose a reason for hiding this comment

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

I don't see my comment. I don't know what would be the best here, but one thing is clear. The max value shouldn't depend on the editor's size max width available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will put as maximum the same we have for images, maximum avatar size * 2.5

alt={ `${ authorName } ${ __( 'Avatar' ) }` }
/>
</ResizableBox>
) : null }
Copy link
Member

Choose a reason for hiding this comment

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

Should it have a fallback when there is no avatar? Some sort of general placeholder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think WordPress by default is putting always an Avatar. In this case the placeholder would appear while fetching the comment data.

Screenshot 2021-10-18 at 17 13 29

Copy link
Member

Choose a reason for hiding this comment

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

Right, but when there are no avatars after fetching is complete, we should also have this fallback included.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What should we put as fallback? A text?
I will take a look if we can put the default image in an easy way.

Copy link
Member

Choose a reason for hiding this comment

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

The image. I even wonder whether it should be resizable.

@cbravobernal
Copy link
Contributor Author

When testing with Safari (macOS), something doesn't work as expected for the block. After I insert the block and move focus to another block (or refresh the page), I'm no longer able to edit the block.

Screen.Recording.2021-10-18.at.17.05.30.mov

That should be fixed. It was due to the lack of a div before the resize component. Could you please check it again? I could not reproduce it completely.

@gziolo
Copy link
Member

gziolo commented Oct 18, 2021

That should be fixed. It was due to the lack of a div before the resize component. Could you please check it again? I could not reproduce it completely.

I had code from 1 hour, so it might be that. I will retest tomorrow 👍🏻

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

We still need to improve how the block can be selected when it occupies the full row. In practice, it might be a less popular option. I suspect that many designs will prefer to use a group block with a flex layout to have a few similar blocks in one line.

Anyway. I think that this PR is good enough to start testing it with other blocks necessary for the Comments Loop block.

@gziolo gziolo merged commit dd1f5ea into WordPress:trunk Oct 27, 2021
@github-actions github-actions bot added this to the Gutenberg 11.9 milestone Oct 27, 2021
@cbravobernal cbravobernal deleted the add/comment-avatar branch October 27, 2021 10:58
@andrewserong andrewserong added the [Type] Feature New feature to highlight in changelogs. label Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository New Block Suggestion for a new block [Package] Block library /packages/block-library [Type] Feature New feature to highlight in changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comment Author Gravatar Block
5 participants