feat(author-profile): avatar and social blocks for nested author profile#4448
feat(author-profile): avatar and social blocks for nested author profile#4448rbcorrales wants to merge 39 commits intotrunkfrom
Conversation
2c4c276 to
65ec32e
Compare
65ec32e to
3a10d54
Compare
There was a problem hiding this comment.
Pull request overview
Adds nested Author Profile rendering support by enhancing the Avatar block to consume author context, introducing new “Author Social Links” inner blocks, and enriching REST author data to reduce editor-side fetches.
Changes:
- Enhanced Avatar block to support nested single-author context, default-avatar fallback, placeholder rendering, and debounced image fetching.
- Added new
author-profile-socialandauthor-social-linkblocks with shared circular icon styling and SVG fallbacks. - Introduced an enriched
newspack_author_infoREST field and updateduseCoAuthorsto support enriched data + deduplicated avatar fetching.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit-tests/bylines/class-test-avatar-block.php | Adds unit tests for enriched REST author info. |
| src/shared/scss/_mixins.scss | Introduces socialButton mixin for consistent social icon button styling. |
| src/shared/hooks/use-coauthors.test.js | Expands hook tests for nicename extraction and avatar fetching/deduping behavior. |
| src/shared/hooks/use-coauthors.js | Updates author mapping, nicename extraction, and per-nicename avatar fetch caching. |
| src/blocks/index.js | Registers the new social blocks (block-theme gated). |
| src/blocks/avatar/style.scss | Renames stacked style selector to overlapped. |
| src/blocks/avatar/hooks.js | Exports useDefaultAvatar for reuse in editor nested fallback. |
| src/blocks/avatar/edit.test.jsx | Adjusts editor test expectations around placeholder rendering. |
| src/blocks/avatar/edit.jsx | Adds nested-context rendering path + fetch debouncing + default avatar fallback. |
| src/blocks/avatar/class-avatar-block.php | Adds nested-context SSR rendering and renames the registered style. |
| src/blocks/avatar/block.json | Extends context usage to include newspack-blocks/author. |
| src/blocks/author-social-link/style.scss | Adds frontend styles for individual social link items. |
| src/blocks/author-social-link/social-icons.js | Adds fallback SVG icon map + SVG getter helper. |
| src/blocks/author-social-link/index.js | Registers the Author Social Link block in JS. |
| src/blocks/author-social-link/edit.js | Implements editor UI rendering for a single social link. |
| src/blocks/author-social-link/class-author-social-link-block.php | Adds SSR for a single social link and SVG fallback support. |
| src/blocks/author-social-link/block.json | Declares block metadata, parent restriction, and contexts used. |
| src/blocks/author-profile-social/style.scss | Adds frontend styles for the social links container/list. |
| src/blocks/author-profile-social/index.js | Registers the Author Social Links container block in JS. |
| src/blocks/author-profile-social/editor.scss | Adds editor-only layout styles for horizontal InnerBlocks. |
| src/blocks/author-profile-social/edit.js | Implements editor container behavior (auto-populate/reset inner links, icon sizing). |
| src/blocks/author-profile-social/class-author-profile-social-block.php | Adds SSR for container block with InnerBlocks + legacy flat render and SVG fallback map. |
| src/blocks/author-profile-social/block.json | Declares block metadata and provides icon-size context to children. |
| includes/plugins/co-authors-plus/class-author-rest-fields.php | Registers newspack_author_info REST field with enriched author data. |
| includes/class-newspack.php | Loads the new REST-field registration class. |
| includes/class-blocks.php | Loads new SSR block classes in block themes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/blocks/author-social-link/class-author-social-link-block.php
Outdated
Show resolved
Hide resolved
|
@laurelfulford thanks for the very detailed review! I fixed the overlapped style issues in 7b82e97. The SVG mask now uses a I think that was the last one pending from the feedback on this particular PR. Let me know if you have any questions or comments. |
|
Thanks @rbcorrales! I'll defer to @thomasguillot's feedback on the overlap, he caught something I did not 🙂 The only other bit outstanding for me was the end-of-story Author Profile (like when it's added to the Site Editor) still seems limited to what social icons it shows -- it seems to just be the ones used in the placeholders. Otherwise I think that's it for this one, thanks for all your hard work and apologies for all the nitpicks! 😅 |
|
Hey @thomasguillot, I wanted to clarify what you meant here. Looking at the screenshots you shared, the expected result actually shows a smaller border radius on the mask (tighter corners on the cutout), not a larger one. Did you mean that the mask radius should account for the gap by subtracting it rather than adding? That's the approach I went with in bb3b3f0: rx = Math.round( Math.max( 0, Math.min( SVG_SIZE / 2, rx - OVERLAP_GAP ) ) * 100 ) / 100;The gap is the visible separator between the overlapping avatars (7.5% of the avatar size on the SVG scale), which comes from the difference between the cutout width (25%) and the overlap amount (17.5%). The idea is that the gap itself contributes to the perceived roundness of the separator corner, so the mask curve needs to be tighter to compensate. The total visual transition (mask curve + gap) then matches the avatar's border radius. A couple of caveats worth noting with this approach:
Let me know if the current result matches what you had in mind or if it needs further tweaking. But unless you feel strongly about this approach, I'd lean towards keeping the original radius without the gap offset. The visual difference is subtle, and it avoids both the maintenance cost of keeping three files in sync and the mismatch near the clamped extremes where the mask and avatar roundness fall out of step. |
|
@rbcorrales it still looks a bit odd but I think it's ok. In my opinion, if you're not using round avatars, you're better off using the default style and not the overlapped one anyway. |
739719f to
d2a93eb
Compare
ea1f6ba to
5325de2
Compare
|
@thomasguillot I committed 620319a, which fixes a duplicate |
|
@laurelfulford I updated the overlap mask math to use your approach from the minimize-math branch as it looked and worked better! I didn't merge it directly because there were conflicts with earlier changes on the same files, so I replicated the logic, did some CSS cleanup, named the geometry values as local variables (so they have a context and look less magical 😄), and updated comments. Let me know if this looks good. |


All Submissions:
Changes proposed in this Pull Request:
This PR provides the blocks that render inside the Author Profile as nested content and updates the Avatar block:
Avatar block enhancements:
newspack-blocks/authorcontext from the parent Author Profile block to render a single author's avatar in nested mode.New social blocks:
newspack/author-profile-social): Container block that renders the author's social media links and email. Reads author data from the parent Author Profile block context.newspack/author-social-link): Individual social link with SVG icon. Supports icon size customization via parent context.socialButtonSCSS mixin that provides consistent circular icon backgrounds across all block themes, using theme color tokens (base-2,base-3,contrast).Other:
newspack_author_infoREST field with avatar URL, social links, and other metadata to reduce editor API calls. Overrides thenewspack-newslettersfield declaration to avoid having that repo as a dependency.useCoAuthorshook updated to support single-author mode for nested context.Closes NPPD-1147.
Related PRs:
How to test the changes in this Pull Request:
Full end-to-end testing steps are in the newspack-blocks PR. The following are additional tests specific to this PR:
Test standalone avatar (no regression):
[Author]shortcode. The avatar should show a placeholder with a diagonal line.Test social block styling independently:
Other information: