Conversation
|
Hey @jahvi! Thanks for working on this. What if the block had a placeholder when you first add it to your post? |
|
Thanks for the feedback @melchoyce that looks great! I'll work on that for the next update. |
a223832 to
a57ce61
Compare
5f358e4 to
c90cecb
Compare
blocks/library/tag-cloud/block.js
Outdated
There was a problem hiding this comment.
Minor: Lodash's _.map, which you're using, will gracefully handle undefined values:
n_ > _.map( undefined, () => '' );
[]
blocks/library/tag-cloud/block.js
Outdated
There was a problem hiding this comment.
I can't help but think that taxonomyRestBase is redundant with taxonomySlug.
You might be able to eliminate it in favor of just the slug, taking advantage of the taxonomy helper included in the argument passed to withAPIData callback:
There was a problem hiding this comment.
Thanks I wasn't aware of the taxonomy helper, it does simplify things a lot!
blocks/library/tag-cloud/block.js
Outdated
There was a problem hiding this comment.
Minor: It may be easier for React to reconcile† this in the render output if it were expressed as an empty value, e.g. null or undefined:
let terms;
if ( termList.data ) {
terms = (
<TermList
terms={ termList.data }
showTagCounts={ showTagCounts }
className={ className }
/>
);
}Or:
const terms = termList.data ? (
<TermList
terms={ termList.data }
showTagCounts={ showTagCounts }
className={ className }
/>
) : null;† The assumption being that it shortcuts to avoid iterating over an empty value.
blocks/library/tag-cloud/editor.scss
Outdated
There was a problem hiding this comment.
These spaces should be tabs.
Use tabs, not spaces, to indent each property.
blocks/library/tag-cloud/index.js
Outdated
There was a problem hiding this comment.
With #4069, align is now simpler to implement for a block via supports.
blocks/library/tag-cloud/index.php
Outdated
There was a problem hiding this comment.
I wouldn't expect align should work here, because you have no attribute schema defined on the server. See the Latest Posts block implementation as an example where attributes are to be defined on the server. These will automatically load into the client, so you don't need to duplicate there.
Eventually the idea is that all blocks will be defined this way : #2751
There was a problem hiding this comment.
You're mutating the original terms reference array here which, based on your usage of the return value termFontSizes below, I don't think is expected.
This might be a good candidate for an Array#map (returning an array of font sizes) or Array#reduce (returning an object of term name => font size).
// Calculate font size for each term
return terms.map( ( term, i ) => {
const countWeight = term.count - lowestCount;
const fontSize = MIN + ( countWeight * fontStep );
return fontSize;
} );There was a problem hiding this comment.
Thanks for pointing it out, I chose to use map since the terms order stays consistent I figured it would make the code simpler.
|
Thanks for your feedback @aduth I just updated my PR. |
blocks/library/tag-cloud/block.js
Outdated
There was a problem hiding this comment.
We could avoid having to implement TermList which is a duplication of wp_tag_cloud() if we used ServerSideRender proposed in #780.
There was a problem hiding this comment.
I agree, not sure what the status of that proposal is but it would have
been useful.
There was a problem hiding this comment.
Ah that's interesting, I'll refactor my PR then
There was a problem hiding this comment.
Just updated the code to use the new ServerSideRender component, it does simplify things quite a lot 🙏🏽
3ac4710 to
7ac38ae
Compare
7ac38ae to
9029500
Compare
|
Just added this to make sure only taxonomies with |
|
It looks like this PR has stalled–I've linked it to the issue so we can use it as prior art, but because it hasn't been worked on in three months I'm going to close it. @jahvi If that's my bad and you were waiting on someone to review something, please let us know and we can re-open this/keep iterating. |
|
Hey @tofumatt I just rebased the latest branches onto this to try to bring this PR back to life (not sure why my latest changes don't show, maybe because PR is closed) I'm having an issue now where my use of the From what I read this HOC is going to be deprecated but I thought it would be safe to use for now as other components are still using it, can anyone advice what the problem might be? I guess something changed in the HOC implementation that prevents this from working as it did before but comparing it with the other components I can't see any major differences. |
|
I managed to make the tag cloud block work with the new |
|
No problem, I just created a new PR #7875 |




Description
This is my attempt at implementing the tag cloud widget as a Gutenberg block, it's still a work in progress but I wanted to get some initial feedback while I'm at it.
Fixes #1801.
I tried to follow the "Categories" block for consistency but there are some areas I'm not sure about:
show_tagcloudastrue, however I'm not sure how to do this, can this be done through the rest API?wp_generate_tag_cloudPHP function in my JS block or is there a better way to get the generated markup?Any feedback would be appreciated! 😀
How Has This Been Tested?
Tested in the latest master branch.
Screenshots (jpeg or gifs if applicable):
Types of changes
New feature: tag cloud block
Checklist: