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
"Releases" Template #246
"Releases" Template #246
Conversation
What do you think about a custom block that pulls the We could also use it on the homepage to match the design closer, and remove this (see #119): wporg-news-2021/source/wp-content/themes/wporg-news-2021/functions.php Lines 376 to 391 in d55bf56
Something similar would work for the date in the Events template. Related: #75 |
I pushed a commit to add a custom block. Seems to work ok. @shaunandrews I've only lightly touched your CSS, the rest of it is additions. To get it to work you'll probably need to:
@iandunn have I added the block plugin in a sane way? I copied the gitignore handling of the theme folder basically. |
.gitignore
Outdated
@@ -30,5 +31,9 @@ README-svn.txt | |||
!/source/wp-content/themes | |||
!/source/wp-content/themes/wporg-news-2021 | |||
|
|||
# And this plugin. | |||
!/source/wp-content/plugins | |||
!/source/wp-content/plugins/wporg-post-title |
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.
🤔 , I'd lean towards putting the code in the blocks/
folder in the mu-plugins
repo, so that all sites can use it. I'd guess that future redesigns will have a similar concept, with part of the post title being used as a design element.
I don't feel strongly, though.
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.
I don't think other sites will need this exact functionality, but if we leave it here that's a third folder we would need to sync into SVN.
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.
If I change it to a more specific block like post-title-version, would any other sites have a use for it? It's a pretty obscure use case. Agree that mu-plugins could make sense for a more generally reusable block though.
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.
Kelly has a good point. I could even seen this being put in functions.php
since it's really just a glorified custom template tag. I wouldn't do that for normal blocks, but this is just a workaround for FSE limitations. I don't feel strongly though.
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.
I'm okay with leaving it in the theme (maybe a blocks
folder, in case we need any other workarounds). If we're still going the parent-theme route, they'll be available to any child themes too. I do think we should use a block.json
+ set it up in JS too, so that it won't break in the site editor (see WordPress/wporg-mu-plugins#26) when we get there.
* | ||
* @return string Returns the filtered post title for the current post wrapped inside "h1" tags. | ||
*/ | ||
function render_block_wporg_post_title( $attributes, $content, $block ) { |
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.
I was imagining something much more simple, that would only be used for this purpose, since core/post-title
can be used if they want the full title.
register_block_type(
'wporg/post-title-version',
array(
'title' => 'Post Title Version',
'render_callback' => function() {
$full_title = get_the_title();
preg_match( '/WordPress (\d+[.]\d+)/', $full_title, $matches );
return $matches[1] ?? '';
}
)
);
That's probably missing a few things, but communicates the jist of it. I don't think we need block.json
etc for a small workaround like this. In my mind this is just a temporary thing until Gutenberg solves WordPress/gutenberg#32939.
"title": "WordPress.org Post Title", | ||
"category": "theme", | ||
"description": "Extends the core Post Title block with additional attributes needed for WordPress.org themes.", |
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.
Aside from the releaseVersion
toggle, how is this different from the Post Title block? Only asking because when I saw "custom block for the version" I thought of making a simple block that only outputs the release version, with no other attributes.
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.
Yeah I like that idea. I guess I was preempting other hypothetical uses for the same block, but I don't think we have any other actual use cases right now.
I changed the block to It feels like overkill. The alternative to adding the block in a plugin is to register a block from the theme itself, which I think(?) is generally discouraged. |
That's true, but that actually was what I was suggesting 😅 I guess it depends on whether you think we'll need this on sites that don't use this theme (itself or as a parent), or if we might want it in the future, whenever this theme is eventually retired. My opinion is that it's decorative in a way that's tied to the theme, so I think keeping it in the theme is fine. |
d25a048
to
f39ac80
Compare
This comment has been minimized.
This comment has been minimized.
f39ac80
to
64620f7
Compare
// Do we also want x.y.z? | ||
if ( preg_match( '/WordPress (\d+[.]\d+)/', $title, $matches ) ) { |
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.
A regex that will work for getting 3rd-level versions is (\d{0,3}(\.\d{1,3})+)
(from here)
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.
👍🏻 It seems important to get .z
in there
Right now the "5.8" version number is duplicated many times, since each of the latest posts (from the import) is for 5.8 release candidates. Would it make sense to update these version numbers to include "RCx" to help reduce the repetition? This might require some design thinking, as I think "5.8 RC2" might be too long to fit within the available space. |
Did you run this? -
|
69413d1
to
a2de6db
Compare
Sorry if this steamrolls WIP @shaunandrews! I added a custom post title block with a `releaseVersion` attribute to output just the version number. Feels like overkill but anything else I came up with was super hacky. It seems to play ok with your CSS, I bodged it a bit to work. Not sure if other styling is needed.
a2de6db
to
33a112d
Compare
@coreymckrill I made a few changes to the block markup, since we don't need to have this in a heading we can avoid the aria workarounds. The content should still be available to screen reader users (just not as a heading). Feel free to undo anything you don't like :) I think all of @beafialho's feedback is still relevant - I removed the arrow on small screens while restructuring some of the CSS, but things like the post height & wonky pagination on small screens are still happening. |
@beafialho @ryelle Sorry I missed that some of the feedback from earlier hadn't been addressed yet. It has been now, would love to get your review. One thing to note is that I also moved the version numbers for the not-latest release posts down to the bottom edge of the rows on mobile to better match the Figma design. |
Thank you @coreymckrill this looks great! |
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.
source/wp-content/themes/wporg-news-2021/sass/page/_categories.scss
Outdated
Show resolved
Hide resolved
source/wp-content/themes/wporg-news-2021/sass/page/_categories.scss
Outdated
Show resolved
Hide resolved
source/wp-content/themes/wporg-news-2021/sass/page/_categories.scss
Outdated
Show resolved
Hide resolved
….scss Co-authored-by: Kelly Dwan <ryelle@users.noreply.github.com>
This PR updates the Releases category template to more closely match the design. It also includes a nifty, new block for displaying a release version number.