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

Improving Related Posts markup as a follow up to jetpack PR 11324 #31023

Closed
wants to merge 1 commit into from

Conversation

aldavigdis
Copy link
Contributor

Changes proposed in this Pull Request

  • Improves the HTML markup and CSS styling in accordance with Related posts improve markup and add alt text jetpack#11324
  • Removes has-small-font-size classes from some HTML elements as this was causing a discrepancy between the editor (where this is defined) and the fronted, where is depends on the theme.

Testing instructions

Test with various themes. Does anything break?

@matticbot
Copy link
Contributor

@aldavigdis aldavigdis requested review from a team February 26, 2019 13:26
height="24"
viewBox="0 0 24 24"
>
<title>{ __( 'Icon for image' ) }</title>
Copy link
Member

@simison simison Feb 26, 2019

Choose a reason for hiding this comment

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

I know this wasn't introduced in this PR, but noting that title is basically ignored by screen readers because SVG component hides the whole icon from screen readers with these props:

'aria-hidden': 'true',
focusable: 'false',

https://github.com/WordPress/gutenberg/blob/e9aac1490cf02ce747eaa6c7291855dba14a1663/packages/components/src/primitives/svg/index.js#L18-L20

Not a blocker for this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is why there is an aria-label in the figure :)

Copy link
Member

@simison simison Feb 26, 2019

Choose a reason for hiding this comment

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

Sure but isn't <title> still redundant? 🙃

<svg aria-hidden>
   <title>...</title>
</svg>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, the Svg component in Gutenberg takes care of the aria-hidden and focusable stuff automatically.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, so that's what I meant to say that <title> isn't needed here at all, because SVG component adds aria-hidden automatically and thus screen readers will never actually read that title. Unless I'm missing something? :-)

Copy link
Member

Choose a reason for hiding this comment

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

In summary, this seems redundant.

Suggested change
<title>{ __( 'Icon for image' ) }</title>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, but it annoys the linter.

Copy link
Member

Choose a reason for hiding this comment

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

I'm confused, which linter/rule? 🙃

@aldavigdis aldavigdis force-pushed the related-posts-imrove-markup branch from cb8d289 to 276d15f Compare February 26, 2019 13:41
@@ -17,95 +17,92 @@ export const MAX_POSTS_TO_SHOW = 6;

function PlaceholderPostEdit( props ) {
return (
<div
<ul
Copy link
Member

Choose a reason for hiding this comment

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

Noting that since different themes introduce padding/margin to ul and li elements, would be good to make sure we reset them so not to have surprises.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is an !important statement in the Sass code that should cover this.

Copy link
Member

@simison simison Feb 26, 2019

Choose a reason for hiding this comment

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

Could we increase specifity in some other way than by using !important which is often a difficult pattern otherwise (https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity)? We just had a similar case with slideshow block #31019

https://wpcalypso.wordpress.com/devdocs/docs/coding-guidelines/css.md#general-syntax-and-writing-rules

Not a blocker for this PR tho!

{ __( 'Preview: Not enough related posts found' ) }
</strong>
<li className="jp-related-posts-i2__post-link">
<a id={ props.id + '-heading' } href={ window.location }>
Copy link
Member

Choose a reason for hiding this comment

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

Would be good to guard against window not existing — this can happen e.g. in our testing setups.

Basically just;

typeof window !== 'undefined'

@simison simison added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 26, 2019
@simison
Copy link
Member

simison commented Feb 26, 2019

Are you targetting this for 7.1? I was hesitant to add milestone if not.

@aldavigdis
Copy link
Contributor Author

@simison — Yes — This need to make it in to 7.1.

@jeherve jeherve added this to the Jetpack: 7.1 milestone Feb 26, 2019
@aldavigdis aldavigdis force-pushed the related-posts-imrove-markup branch from 276d15f to 7a3fe93 Compare February 26, 2019 16:12
@jeherve jeherve modified the milestones: Jetpack: 7.1, Jetpack: 7.2 Feb 26, 2019
@simison simison requested a review from a team February 27, 2019 08:37
@simison simison added the [Goal] Gutenberg Working towards full integration with Gutenberg label Feb 27, 2019
className="jp-related-posts-i2__post-image-placeholder-figure-square"
xmlns="http://www.w3.org/2000/svg"
width="100%"
height="100%"
Copy link
Member

Choose a reason for hiding this comment

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

I don't believe 100% are valid values for width and height attributes. They should be integers representing a value in CSS pixels.

https://html.spec.whatwg.org/#dimension-attributes

Styling of this type should be handled by CSS.

height="24"
viewBox="0 0 24 24"
>
<title>{ __( 'Icon for image' ) }</title>
Copy link
Member

Choose a reason for hiding this comment

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

In summary, this seems redundant.

Suggested change
<title>{ __( 'Icon for image' ) }</title>

@@ -17,95 +17,95 @@ export const MAX_POSTS_TO_SHOW = 6;

function PlaceholderPostEdit( props ) {
Copy link
Member

Choose a reason for hiding this comment

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

Whoa, there are 4 components defined in this file! I strongly prefer 1 component 1 file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are all dependencies of a master component.

@aldavigdis aldavigdis force-pushed the related-posts-imrove-markup branch from 7a3fe93 to 7155cbe Compare March 11, 2019 17:36
@simison simison removed this from the Jetpack: 7.2 milestone Mar 28, 2019
@sarayourfriend sarayourfriend changed the base branch from master to trunk November 20, 2020 16:15
@sirreal sirreal closed this Nov 27, 2020
@sirreal sirreal deleted the related-posts-imrove-markup branch November 27, 2020 11:01
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Goal] Gutenberg Working towards full integration with Gutenberg Related Posts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants