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

"Contributors" styles #355

Closed
coreymckrill opened this issue Feb 26, 2022 · 13 comments · Fixed by #363
Closed

"Contributors" styles #355

coreymckrill opened this issue Feb 26, 2022 · 13 comments · Fixed by #363
Assignees
Labels
[Type] Enhancement New feature or request

Comments

@coreymckrill
Copy link
Contributor

The design specifies color and font size that depends on how long the list of contributors is:

contributors

It appears (for the 5.9 release anyway) that the list of contributors is just output in a single paragraph block. So perhaps these three "breakpoint" styles should just be implemented as block variations for the paragraph block?

@coreymckrill coreymckrill added the [Type] Enhancement New feature or request label Feb 26, 2022
@coreymckrill coreymckrill added this to the Post-Launch Iteration 1 milestone Feb 26, 2022
@ryelle
Copy link
Contributor

ryelle commented Feb 28, 2022

Maybe it should be a custom block that uses the contributors API endpoint? (like core does for /credits.php)

@coreymckrill
Copy link
Contributor Author

I could get behind that idea...

With something like credits, it seems like we'd want the list of names to actually be inserted into the post content, instead of it being a dynamic block whose output comes from PHP. This would be beneficial because A) the results would be cached in post content, so less calls to the API, and B) the names would still be there if the API ever changed.

But maybe the block would have UI in the editor for "refreshing" the name list, if e.g. the contributor list gets updated later, which would remove and replace the list of names with the results of a new API call (although I guess you could just remove the block and re-add it?)

@coreymckrill coreymckrill self-assigned this Mar 14, 2022
@coreymckrill
Copy link
Contributor Author

coreymckrill commented Mar 15, 2022

🤔 It looks like it might not be possible to use the API endpoint for every release post. The problem is that the API only stores credits data for major releases, and treats minor releases as having the same set of contributors. So the credits list for 5.9.0 and for 5.9.x are the same.

Currently in release posts on the News site, minor versions, betas, and RCs only give props to the contributors who contributed for that particular release, rather than the entire major version.

I also learned that the HTML list of contributors that currently gets pasted into release posts is generated by a bin script that exists on wporg sandboxes, and basically parses a git log to find all the users. I don't think there's a good way to automate that at this point.

So, I think we're back to either creating a custom style for the Paragraph block, or creating a simple "Props" block. Given that the list of names still has to get generated from a script, whether or not its marked up with HTML or not, a custom style seems like the best choice.

@coreymckrill
Copy link
Contributor Author

Ok, I wasn't thorough enough in my investigation before. Some release posts use a [wpcredits] shortcode (mostly the major version release posts). Others use a block of HTML generated by a sandbox script.

So we may be able to make a block version of that shortcode. But I think the first step is to register some block styles on the paragraph block that will apply a class like is-style-wporg-props-medium to the paragraph element. Then we can make sure that the shortcode adds that class to its output so that the styles get applied (the Shortcode block doesn't get rendered with a container element, so I suspect we can't register block styles for it). There are three different variations of the style (see screenshot above) depending on the length of the props list, so we may also need to add a parameter to the shortcode to account for that.

@iandunn
Copy link
Member

iandunn commented Mar 16, 2022

the Shortcode block doesn't get rendered with a container element, so I suspect we can't register block styles for it)

We added a p wrapper in https://meta.trac.wordpress.org/changeset/11344/ to fix #87, so I'm guessing it's just the old manual ones that don't have it.

@coreymckrill
Copy link
Contributor Author

Oh yeah, they get a p wrapper from the shortcode render itself. I just mean if you add a Shortcode block to the post content with [wpcredits] inside it, you don't get something like <div class="wp-block-shortcode">{shortcode content}</div> so you can't really do a register_block_style() call for it.

@iandunn
Copy link
Member

iandunn commented Mar 16, 2022

Ah, I see 👍🏻

@coreymckrill
Copy link
Contributor Author

coreymckrill commented Mar 16, 2022

The way the design is now, the usernames are supposed to have a dot/bullet between each one. This could be accomplished with something like an :after style rule. However, the current HTML generated by the shortcode and sandbox script separates each username with a comma. Having both a comma and a bullet would look pretty weird.

One way to visually fix it might be to have the paragraph text be the same color as the background, so it's essentially hidden, and then have anchor tags within the paragraph have the correct (white) text color. Then the only weirdness would be at the end of the list of props where the last username is prefixed with an "and", so there would be kind of a big gap between the last two items.

Another potential fix would be to change the output of the shortcode to not have commas or the final "and" (maybe change it to a bulleted list that we can then style so list items are inline?), but that wouldn't address older posts that have the script-generated list.

Thoughts @beafialho @iandunn ?

@tellyworth
Copy link
Contributor

What about adding a shortcode argument, so [wpcredits separator="•"] works for the new posts, and the old ones are unchanged?

@iandunn
Copy link
Member

iandunn commented Mar 17, 2022

I like that better, since the text/background match feels pretty hacky and might be misinterpreted as spam by search engines.

The shortcode could also take a bool arg that determines whether or not the "and" is added. Those new args could add classes to the containing p that we could target w/ styles.

IMO it's fine to leave older posts alone, but I don't feel strongly.

@beafialho
Copy link
Collaborator

What about adding a shortcode argument, so [wpcredits separator="•"] works for the new posts, and the old ones are unchanged?

This also seems better to me because of the hacky/spam point noted by @iandunn. I'd like to use [wpcredits separator="·"] instead for a more minimal separator.

coreymckrill added a commit to WordPress/wordpress.org that referenced this issue Mar 25, 2022
Adds `class` and `separator` attributes to the shortcode callback
function so that the string of props names can better be styled to
match the new design for the WordPress.org News site.

The defaults for these attributes are set so that all existing uses
of the shortcode on the News site will be able to match the design
without having to go back and edit a lot of posts.

See WordPress/wporg-news-2021#355
coreymckrill added a commit that referenced this issue Mar 28, 2022
Registers some block styles and adds related rules to the stylesheet to match the design for "Contributors" blocks. In some release posts (major releases), the [wpcredits] shortcode is used, which can't have the block styles applied to it, so there's a separate PR to add the correct classes to the container that it renders. For other release posts (minor releases), the list of props is usually generated via a script and pasted into a paragraph or code block. For these, the block style can be applied manually to be able to match the design.

Note that the design calls for the props block to be full width. It seemed to make more sense to just have the post author add the additional alignfull class to the block, rather than trying to match the same full width styles with another class name.

Fixes #355
@coreymckrill
Copy link
Contributor Author

@beafialho
Copy link
Collaborator

Uh oh, I realized now I missed this ping @coreymckrill... All these sizes are looking great. Thank you all for your hard work on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants