-
Notifications
You must be signed in to change notification settings - Fork 2k
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 full post page - add global sidebar and content frame #91990
Merged
Addison-Stavlo
merged 16 commits into
trunk
from
update/full-post-view-for-global-sidebar
Jun 26, 2024
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e17d1fd
add reader sidebar to full post pages
Addison-Stavlo dd039ed
remove css not conditions for reader-full-post page
Addison-Stavlo b8560c4
add div around reader full post content for consistency
Addison-Stavlo e8018c9
make full post content a flex container
Addison-Stavlo 738664f
ensure padding for story content
Addison-Stavlo a4361b9
hide author details when they don't fit on side
Addison-Stavlo 95c269f
handle back functionality better
Addison-Stavlo a8a6d93
move tracking for close article to trigger from sidebar as well
Addison-Stavlo 0fea3a5
adjust margins and paddings
Addison-Stavlo a5ebbcb
fix back button
Addison-Stavlo 2aefa3a
fix back button hiding title at mobile widths
Addison-Stavlo 0f36bf1
fix reader related card meta issues breaking layout
Addison-Stavlo ad51b29
cleanup commented out goo
Addison-Stavlo 68d5a35
remove need to pass post into the close callback
Addison-Stavlo 234e93f
update margins
Addison-Stavlo 62c8a2e
Few minor style updates
davemart-in File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,11 +214,7 @@ export class FullPostView extends Component { | |
|
||
handleBack = ( event ) => { | ||
event.preventDefault(); | ||
recordAction( 'full_post_close' ); | ||
recordGaEvent( 'Closed Full Post Dialog' ); | ||
recordTrackForPost( 'calypso_reader_article_closed', this.props.post ); | ||
|
||
this.props.onClose && this.props.onClose(); | ||
this.props.onClose && this.props.onClose( this.props.post ); | ||
}; | ||
|
||
handleCommentClick = () => { | ||
|
@@ -498,191 +494,194 @@ export class FullPostView extends Component { | |
/*eslint-disable react/no-danger */ | ||
/*eslint-disable react/jsx-no-target-blank */ | ||
return ( | ||
<ReaderMain className={ clsx( classes ) }> | ||
{ site && <QueryPostLikes siteId={ post.site_ID } postId={ post.ID } /> } | ||
{ ! post || post._state === 'pending' ? ( | ||
<DocumentHead title={ translate( 'Loading' ) } /> | ||
) : ( | ||
<DocumentHead title={ `${ post.title } ‹ ${ siteName } ‹ Reader` } /> | ||
) } | ||
{ post && post.feed_ID && <QueryReaderFeed feedId={ +post.feed_ID } /> } | ||
{ post && ! post.is_external && post.site_ID && ( | ||
<QueryReaderSite siteId={ +post.site_ID } /> | ||
) } | ||
{ referral && ! referralPost && <QueryReaderPost postKey={ referral } /> } | ||
{ ! post || ( isLoading && <QueryReaderPost postKey={ postKey } /> ) } | ||
<BackButton onClick={ this.handleBack } /> | ||
<div className="reader-full-post__visit-site-container"> | ||
<ExternalLink | ||
icon | ||
href={ post.URL } | ||
onClick={ this.handleVisitSiteClick } | ||
target="_blank" | ||
> | ||
<span className="reader-full-post__visit-site-label"> | ||
{ translate( 'Visit Site' ) } | ||
</span> | ||
</ExternalLink> | ||
</div> | ||
<div className="reader-full-post__content"> | ||
<div className="reader-full-post__sidebar"> | ||
{ isLoading && <AuthorCompactProfile author={ null } /> } | ||
{ ! isLoading && post.author && ( | ||
<AuthorCompactProfile | ||
author={ post.author } | ||
siteIcon={ get( site, 'icon.img' ) } | ||
feedIcon={ feedIcon } | ||
siteName={ siteName } | ||
siteUrl={ post.site_URL } | ||
feedUrl={ get( post, 'feed_URL' ) } | ||
followCount={ site && site.subscribers_count } | ||
onFollowToggle={ this.openSuggestedFollowsModal } | ||
feedId={ +post.feed_ID } | ||
siteId={ +post.site_ID } | ||
post={ post } | ||
/> | ||
) } | ||
<div className="reader-full-post__sidebar-comment-like"> | ||
{ userCan( 'edit_post', post ) && ( | ||
<PostEditButton | ||
// add extra div wrapper for consistent content frame layout/styling for reader. | ||
<div> | ||
Comment on lines
+497
to
+498
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While the changes here look like a lot, all I have done is wrap everything in an empty div. This makes the structure more consistent with the rest of the reader and able to inherit the content frame styles appropriately. |
||
<ReaderMain className={ clsx( classes ) }> | ||
{ site && <QueryPostLikes siteId={ post.site_ID } postId={ post.ID } /> } | ||
{ ! post || post._state === 'pending' ? ( | ||
<DocumentHead title={ translate( 'Loading' ) } /> | ||
) : ( | ||
<DocumentHead title={ `${ post.title } ‹ ${ siteName } ‹ Reader` } /> | ||
) } | ||
{ post && post.feed_ID && <QueryReaderFeed feedId={ +post.feed_ID } /> } | ||
{ post && ! post.is_external && post.site_ID && ( | ||
<QueryReaderSite siteId={ +post.site_ID } /> | ||
) } | ||
{ referral && ! referralPost && <QueryReaderPost postKey={ referral } /> } | ||
{ ! post || ( isLoading && <QueryReaderPost postKey={ postKey } /> ) } | ||
<BackButton onClick={ this.handleBack } /> | ||
<div className="reader-full-post__visit-site-container"> | ||
<ExternalLink | ||
icon | ||
href={ post.URL } | ||
onClick={ this.handleVisitSiteClick } | ||
target="_blank" | ||
> | ||
<span className="reader-full-post__visit-site-label"> | ||
{ translate( 'Visit Site' ) } | ||
</span> | ||
</ExternalLink> | ||
</div> | ||
<div className="reader-full-post__content"> | ||
<div className="reader-full-post__sidebar"> | ||
{ isLoading && <AuthorCompactProfile author={ null } /> } | ||
{ ! isLoading && post.author && ( | ||
<AuthorCompactProfile | ||
author={ post.author } | ||
siteIcon={ get( site, 'icon.img' ) } | ||
feedIcon={ feedIcon } | ||
siteName={ siteName } | ||
siteUrl={ post.site_URL } | ||
feedUrl={ get( post, 'feed_URL' ) } | ||
followCount={ site && site.subscribers_count } | ||
onFollowToggle={ this.openSuggestedFollowsModal } | ||
feedId={ +post.feed_ID } | ||
siteId={ +post.site_ID } | ||
post={ post } | ||
site={ site } | ||
iconSize={ 20 } | ||
onClick={ this.onEditClick } | ||
/> | ||
) } | ||
<div className="reader-full-post__sidebar-comment-like"> | ||
{ userCan( 'edit_post', post ) && ( | ||
<PostEditButton | ||
post={ post } | ||
site={ site } | ||
iconSize={ 20 } | ||
onClick={ this.onEditClick } | ||
/> | ||
) } | ||
|
||
{ shouldShowComments( post ) && ( | ||
<CommentButton | ||
key="comment-button" | ||
commentCount={ commentCount } | ||
onClick={ this.handleCommentClick } | ||
tagName="div" | ||
icon={ ReaderCommentIcon( { iconSize: 20 } ) } | ||
/> | ||
) } | ||
|
||
{ shouldShowLikes( post ) && ( | ||
<LikeButton | ||
siteId={ +post.site_ID } | ||
postId={ +post.ID } | ||
fullPost | ||
tagName="div" | ||
likeSource="reader" | ||
/> | ||
) } | ||
|
||
{ shouldShowComments( post ) && ( | ||
<CommentButton | ||
key="comment-button" | ||
commentCount={ commentCount } | ||
onClick={ this.handleCommentClick } | ||
tagName="div" | ||
icon={ ReaderCommentIcon( { iconSize: 20 } ) } | ||
{ isEligibleForUnseen( { isWPForTeamsItem, hasOrganization } ) && | ||
canBeMarkedAsSeen( { post } ) && | ||
this.renderMarkAsSenButton() } | ||
</div> | ||
</div> | ||
<article className="reader-full-post__story"> | ||
<ReaderFullPostHeader post={ post } referralPost={ referralPost } /> | ||
|
||
{ post.featured_image && ! isFeaturedImageInContent( post ) && ( | ||
<ReaderFeaturedImage | ||
canonicalMedia={ null } | ||
imageUrl={ post.featured_image } | ||
href={ getStreamUrlFromPost( post ) } | ||
imageWidth={ contentWidth } | ||
children={ <div style={ { width: contentWidth } } /> } | ||
/> | ||
) } | ||
{ isLoading && <ReaderFullPostContentPlaceholder /> } | ||
{ post.use_excerpt ? ( | ||
<PostExcerpt content={ post.better_excerpt ? post.better_excerpt : post.excerpt } /> | ||
) : ( | ||
<EmbedContainer> | ||
<AutoDirection> | ||
<div | ||
ref={ this.postContentWrapper } | ||
className="reader-full-post__story-content" | ||
dangerouslySetInnerHTML={ { __html: post.content } } | ||
/> | ||
</AutoDirection> | ||
</EmbedContainer> | ||
) } | ||
|
||
{ post.use_excerpt && <PostExcerptLink siteName={ siteName } postUrl={ post.URL } /> } | ||
{ isDailyPostChallengeOrPrompt( post ) && ( | ||
<DailyPostButton post={ post } site={ site } /> | ||
) } | ||
|
||
<ReaderPostActions | ||
post={ post } | ||
site={ site } | ||
onCommentClick={ this.handleCommentClick } | ||
fullPost | ||
/> | ||
|
||
{ ! isLoading && <ReaderPerformanceTrackerStop /> } | ||
|
||
{ shouldShowLikes( post ) && ( | ||
<LikeButton | ||
{ showRelatedPosts && ( | ||
<RelatedPostsFromSameSite | ||
siteId={ +post.site_ID } | ||
postId={ +post.ID } | ||
fullPost | ||
tagName="div" | ||
likeSource="reader" | ||
title={ translate( 'More in {{ siteLink /}}', { | ||
components: { | ||
siteLink: ( | ||
<a | ||
href={ getStreamUrlFromPost( post ) } | ||
/* eslint-disable wpcalypso/jsx-classname-namespace */ | ||
className="reader-related-card__link" | ||
/* eslint-enable wpcalypso/jsx-classname-namespace */ | ||
> | ||
{ siteName } | ||
</a> | ||
), | ||
}, | ||
} ) } | ||
/* eslint-disable wpcalypso/jsx-classname-namespace */ | ||
className="is-same-site" | ||
/* eslint-enable wpcalypso/jsx-classname-namespace */ | ||
onPostClick={ this.handleRelatedPostFromSameSiteClicked } | ||
/> | ||
) } | ||
|
||
{ isEligibleForUnseen( { isWPForTeamsItem, hasOrganization } ) && | ||
canBeMarkedAsSeen( { post } ) && | ||
this.renderMarkAsSenButton() } | ||
</div> | ||
</div> | ||
<article className="reader-full-post__story"> | ||
<ReaderFullPostHeader post={ post } referralPost={ referralPost } /> | ||
|
||
{ post.featured_image && ! isFeaturedImageInContent( post ) && ( | ||
<ReaderFeaturedImage | ||
canonicalMedia={ null } | ||
imageUrl={ post.featured_image } | ||
href={ getStreamUrlFromPost( post ) } | ||
imageWidth={ contentWidth } | ||
children={ <div style={ { width: contentWidth } } /> } | ||
/> | ||
) } | ||
{ isLoading && <ReaderFullPostContentPlaceholder /> } | ||
{ post.use_excerpt ? ( | ||
<PostExcerpt content={ post.better_excerpt ? post.better_excerpt : post.excerpt } /> | ||
) : ( | ||
<EmbedContainer> | ||
<AutoDirection> | ||
<div | ||
ref={ this.postContentWrapper } | ||
className="reader-full-post__story-content" | ||
dangerouslySetInnerHTML={ { __html: post.content } } | ||
<div className="reader-full-post__comments-wrapper" ref={ this.commentsWrapper }> | ||
{ shouldShowComments( post ) && ( | ||
<Comments | ||
showNestingReplyArrow | ||
post={ post } | ||
initialSize={ startingCommentId ? commentCount : 10 } | ||
pageSize={ 25 } | ||
startingCommentId={ startingCommentId } | ||
commentCount={ commentCount } | ||
maxDepth={ 1 } | ||
commentsFilterDisplay={ COMMENTS_FILTER_ALL } | ||
showConversationFollowButton | ||
shouldPollForNewComments={ config.isEnabled( 'reader/comment-polling' ) } | ||
shouldHighlightNew | ||
/> | ||
</AutoDirection> | ||
</EmbedContainer> | ||
) } | ||
|
||
{ post.use_excerpt && <PostExcerptLink siteName={ siteName } postUrl={ post.URL } /> } | ||
{ isDailyPostChallengeOrPrompt( post ) && ( | ||
<DailyPostButton post={ post } site={ site } /> | ||
) } | ||
|
||
<ReaderPostActions | ||
post={ post } | ||
site={ site } | ||
onCommentClick={ this.handleCommentClick } | ||
fullPost | ||
/> | ||
) } | ||
</div> | ||
|
||
{ ! isLoading && <ReaderPerformanceTrackerStop /> } | ||
|
||
{ showRelatedPosts && ( | ||
<RelatedPostsFromSameSite | ||
siteId={ +post.site_ID } | ||
postId={ +post.ID } | ||
title={ translate( 'More in {{ siteLink /}}', { | ||
components: { | ||
siteLink: ( | ||
<a | ||
href={ getStreamUrlFromPost( post ) } | ||
/* eslint-disable wpcalypso/jsx-classname-namespace */ | ||
className="reader-related-card__link" | ||
/* eslint-enable wpcalypso/jsx-classname-namespace */ | ||
> | ||
{ siteName } | ||
</a> | ||
), | ||
}, | ||
} ) } | ||
/* eslint-disable wpcalypso/jsx-classname-namespace */ | ||
className="is-same-site" | ||
/* eslint-enable wpcalypso/jsx-classname-namespace */ | ||
onPostClick={ this.handleRelatedPostFromSameSiteClicked } | ||
/> | ||
) } | ||
|
||
<div className="reader-full-post__comments-wrapper" ref={ this.commentsWrapper }> | ||
{ shouldShowComments( post ) && ( | ||
<Comments | ||
showNestingReplyArrow | ||
post={ post } | ||
initialSize={ startingCommentId ? commentCount : 10 } | ||
pageSize={ 25 } | ||
startingCommentId={ startingCommentId } | ||
commentCount={ commentCount } | ||
maxDepth={ 1 } | ||
commentsFilterDisplay={ COMMENTS_FILTER_ALL } | ||
showConversationFollowButton | ||
shouldPollForNewComments={ config.isEnabled( 'reader/comment-polling' ) } | ||
shouldHighlightNew | ||
{ showRelatedPosts && ( | ||
<RelatedPostsFromOtherSites | ||
siteId={ +post.site_ID } | ||
postId={ +post.ID } | ||
title={ relatedPostsFromOtherSitesTitle } | ||
/* eslint-disable wpcalypso/jsx-classname-namespace */ | ||
className="is-other-site" | ||
/* eslint-enable wpcalypso/jsx-classname-namespace */ | ||
onPostClick={ this.handleRelatedPostFromOtherSiteClicked } | ||
/> | ||
) } | ||
</div> | ||
|
||
{ showRelatedPosts && ( | ||
<RelatedPostsFromOtherSites | ||
siteId={ +post.site_ID } | ||
postId={ +post.ID } | ||
title={ relatedPostsFromOtherSitesTitle } | ||
/* eslint-disable wpcalypso/jsx-classname-namespace */ | ||
className="is-other-site" | ||
/* eslint-enable wpcalypso/jsx-classname-namespace */ | ||
onPostClick={ this.handleRelatedPostFromOtherSiteClicked } | ||
/> | ||
) } | ||
</article> | ||
</div> | ||
{ post.site_ID && ( | ||
<ReaderSuggestedFollowsDialog | ||
onClose={ this.onCloseSuggestedFollowModal } | ||
siteId={ +post.site_ID } | ||
postId={ +post.ID } | ||
isVisible={ this.state.isSuggestedFollowsModalOpen } | ||
/> | ||
) } | ||
</ReaderMain> | ||
</article> | ||
</div> | ||
{ post.site_ID && ( | ||
<ReaderSuggestedFollowsDialog | ||
onClose={ this.onCloseSuggestedFollowModal } | ||
siteId={ +post.site_ID } | ||
postId={ +post.ID } | ||
isVisible={ this.state.isSuggestedFollowsModalOpen } | ||
/> | ||
) } | ||
</ReaderMain> | ||
</div> | ||
); | ||
} | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Moved these into the controller where the onClose is defined so closing via the sidebar can send them as well.