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

feat: custom byline interfce #3746

Open
wants to merge 18 commits into
base: trunk
Choose a base branch
from
Open

Conversation

allysonsouza
Copy link
Collaborator

@allysonsouza allysonsouza commented Feb 12, 2025

All Submissions:

Changes proposed in this Pull Request:

This Pull Request implements the feature to allow the selection of author tokens from authors selected on Co-Authors Plus to compound a custom byline with them.

How to test the changes in this Pull Request:

  1. Go to a post edit page and assign authors to the post on co-authors plus panel
  2. Below it, you will see the Newspack Custom Byline panel. Set the toggle to active to enable custom byline.
  3. You will see the custom byline field, which is a div with contenteditable. Below it you should see the authors assigned to the post as buttons that will insert the tokens on the content when clicked.
  4. Click on buttons to add the token to the content
  5. Click on buttons inside the byline content to remove token
  6. Also, the tokens should be removed when editions are made to then with delete/backspace for example
  7. Save the post, reload the page and see if the custom byline saved is what is expected
  8. Check if the custom byline is editable as expected too after saving it

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@allysonsouza allysonsouza self-assigned this Feb 12, 2025
@allysonsouza allysonsouza changed the title Feat: custom byline interfce feat: custom byline interfce Feb 12, 2025
@allysonsouza allysonsouza added the [Status] Needs Review The issue or pull request needs to be reviewed label Feb 13, 2025
@allysonsouza allysonsouza marked this pull request as ready for review February 13, 2025 18:44
@allysonsouza allysonsouza requested a review from a team as a code owner February 13, 2025 18:44
Copy link
Contributor

@claudiulodro claudiulodro left a comment

Choose a reason for hiding this comment

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

Overall I think this is coming together! The UX of it feels good. I noticed a few quirks in my testing:

  1. In general it's kind of hard to read once there are a few authors in there:
Screenshot 2025-02-13 at 1 29 49 PM

Not sure if we should reduce the size of the author boxes or how best to handle that. What do you think, @thomasguillot?

  1. Using the arrow keys, you can go into one of the boxes and then type to modify the content. I think it should not be editable.
Screenshot 2025-02-13 at 1 31 01 PM
  1. If you select a portion of the text that includes a box and delete, the box doesn't go back into the available authors section:
Screenshot 2025-02-13 at 1 33 24 PM Screenshot 2025-02-13 at 1 33 34 PM
  1. Authors are always inserted at the end of the text box. I think the best experience would be for them to be inserted at the cursor position, otherwise it's tricky to edit existing bylines to add/change authors around.

@leogermani
Copy link
Contributor

This is starting to look pretty good!

Here are two things I noticed:

  • This feature should also work without CoAuthors Plus. In that case, it would list only the normal post author
  • The input should be pre-filled with the default by byline
  • The value stored in the post meta field should follow what's described here

The idea of storing the ID and the name is to have a fallback in case the user is deleted. When we render the byline, we'll always read the ID and get the Display name from the database, but if the ID is gone, we'll use the name that is stored there.

@leogermani
Copy link
Contributor

Ah, and before you get crazy and go deep in a rabbit role, we DON'T NEED TO SUPPORT Guest Authors

@claudiulodro claudiulodro added [Status] Needs changes or feedback The issue or pull request needs action from the original creator and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Feb 13, 2025
@thomasguillot
Copy link
Contributor

Overall I think this is coming together! The UX of it feels good. I noticed a few quirks in my testing:

  1. In general it's kind of hard to read once there are a few authors in there:
Screenshot 2025-02-13 at 1 29 49 PM Not sure if we should reduce the size of the author boxes or how best to handle that. What do you think, @thomasguillot?

You're right, this doesn't look good. Let me think about a different approach here.

@thomasguillot
Copy link
Contributor

Note: The panel should simply be named "Byline", not "Newspack Custom Byline"

@thomasguillot
Copy link
Contributor

Can we please make sure the style matches Core's FormTokenField

Also we can use @wordpress/base-styles/colors rather than hardcoding the values.

@miguelpeixe
Copy link
Member

I've just tested on a fresh post and I still have issues with the backspace interaction:

custom-byline.mov

Another problem I faced while drafting the new post was that the additional authors only became available after I saved and refreshed the post. Ideally, the component would be aware of the edited changes and update the component's available tokens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Needs changes or feedback The issue or pull request needs action from the original creator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants