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

Reader: Discover featured posts accessibility improvements #27089

Merged
merged 5 commits into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions client/reader/site-stream/featured.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ function getPostUrl( post ) {
return '/read/blogs/' + post.site_ID + '/posts/' + post.ID;
}

const FEED_FEATURED_MAX_POST_COUNT = 3;

/* eslint-disable wpcalypso/jsx-classname-namespace */
// This component is used in the Discover site stream only.
class FeedFeatured extends React.PureComponent {
static displayName = 'FeedFeatured';

componentDidMount() {
this.props.requestPage( { streamKey: this.props.streamKey } );
if ( ! this.props.posts || this.props.posts.length < FEED_FEATURED_MAX_POST_COUNT ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously, it was possible for the same set of posts to appear twice if the component re-mounted.

this.props.requestPage( { streamKey: this.props.streamKey } );
}
}

handleClick = postData => {
Expand Down Expand Up @@ -63,14 +68,14 @@ class FeedFeatured extends React.PureComponent {
};

return (
<div
<button
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe make this a big anchor instead of a button? It has a URL after all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's actually a better idea than my button, but also scuppers all the styles, especially in the small viewport version 🤦‍♂️

I'll ship this for now and bear it in mind for future improvements 👍

key={ post.ID }
className="reader__featured-post"
onClick={ this.handleClick.bind( this, postData ) }
>
<div className="reader__featured-post-image" style={ style } />
<h2 className="reader__featured-post-title">{ post.title }</h2>
</div>
</button>
);
}
} );
Expand Down
21 changes: 15 additions & 6 deletions client/reader/site-stream/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Featured Posts Area

// Featured Posts
.reader__featured-card {
padding: 16px 24px 0;
margin-bottom: 24px;
Expand Down Expand Up @@ -34,9 +33,11 @@
}

.reader__featured-post {
border: 0;
box-sizing: content-box;
position: relative;
min-height: 52px;
padding: 32px 24px;
margin: 0;
min-height: 118px;
background-color: $gray-dark;
transition: all 0.1s ease-in-out;
cursor: pointer;
Expand All @@ -45,7 +46,7 @@
// Break into 3 columns on larger screens
@include breakpoint( ">960px" ) {
flex: 1;
min-height: 152px;
min-height: 216px;

&:hover {
background-color: $gray-darken-30;
Expand All @@ -65,10 +66,18 @@
}

.reader__featured-post-title {
color: $white;
position: relative;
padding: 0 24px;
font-family: $serif;
font-weight: 700;
font-size: 18px;
color: $white;
line-height: 1.5;
text-align: left;
z-index: z-index( 'root', '.reader__featured-post-title' );

@include breakpoint( ">960px" ) {
position: absolute;
top: 32px;
}
}