-
Notifications
You must be signed in to change notification settings - Fork 58
feat: Add My Account button block #4409
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
base: trunk
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR adds a new "My Account Button" block to Newspack Plugin, allowing sites with Reader Activation enabled to display a dynamic button that links readers to their account page or opens the sign-in modal. The block adapts its label and behavior based on authentication state.
Changes:
- Added a new My Account Button block with dynamic labels for signed-in and signed-out states
- Moved CSS styles from reader-activation-auth to allow reuse by the new block
- Added account icon to the icons package
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/blocks/my-account-button/class-my-account-button-block.php | Server-side block rendering with authentication state handling and WooCommerce account URL detection |
| src/blocks/my-account-button/edit.js | Block editor component with toolbar toggle for previewing signed-in/out states |
| src/blocks/my-account-button/block.json | Block metadata with support for color, typography, spacing, and border customization |
| src/blocks/my-account-button/style.scss | Block styles including disabled state and icon sizing |
| src/blocks/my-account-button/index.js | Block registration with icon configuration |
| src/blocks/my-account-button/README.md | Documentation describing block behavior and settings |
| src/blocks/index.js | Registration logic preventing block from appearing in classic themes |
| packages/icons/src/account.js | New account SVG icon |
| packages/icons/index.js | Export for new account icon |
| includes/class-blocks.php | Include block PHP class and pass block theme flag to editor |
| src/reader-activation-auth/style.scss | Removed account link styles (moved to block-specific styles) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks @thomasguillot!
The logic in the RAS code only switches the button to the signed in state when you're a registered reader and not when you're logged in. I can do this differently in the block and just have it show the signed in label for anyone who's logged in, but I didn't know the history of that choice re: making it reader specific. Do you? |
Isn't it the same thing? 😕 |
|
@laurelfulford I pushed some changes. Basically instead of having yet another custom button block, I think we should leverage Core's button block markup (note: I haven't looked at the editor and it might be broken) |
|
Thanks @thomasguillot!
That's a good call! I'll take a look at the editor...
Not quite - it distinguishes between someone who's been registered through reader registration vs. other WordPress roles (like editor or administrator). Right now the button's hidden if you're logged into the other roles (unless you're in the Customizer) so what it shows to the publisher is kind of moot in the classic theme. We could just make it visible and treat all logged in users the same if that makes more sense to you? I can ask the wider team if this would cause issues for some reason -- I don't remember the decision making behind this. |
|
@thomasguillot So far it sounds like the main concern was creating kind of a dead end for admins/editors since they don't need to use /my-account. What would be your preference for how it behaves for logged in publishers: look/act the same as for readers (say "My Account" and link to /my-account) or do something else that (somehow) indicates it's for readers. I'm thinking like how the Newspack Subscription block doesn't let you subscribe as a admin/editor 🤔 |
This 👍 |
|
Thanks @thomasguillot! I've made the following changes:
One last thing from me: what do you think we should do for mobile? I was thinking either make the button only show the icon on small screens, or have an icon-only style as an option that can be added to the mobile header. Or maybe a third option - do you have any preferences? |

All Submissions:
Changes proposed in this Pull Request:
This PR, along with Automattic/newspack-block-theme#400 and Automattic/newspack-theme#2618 adds a My Account button block to the Newspack Plugin, adds the button to just one pattern (for now) in the Block Theme (for testing), and moves some CSS from the Newspack Plugin to the classic theme to avoid clashing.
I have some open questions/possible weird cruft to still deal with:
Some of these (like the mobile state, and maybe adding an 'Outline' style) can also be handled in a separate PR if there isn't a for-sure direction to follow.
See NPPD-1123.
How to test the changes in this Pull Request:
Other information: