From: Dessalines Date: Thu, 25 Mar 2021 16:44:16 +0000 (-0400) Subject: Adding expandable post texts by clicking on book. Fixes #225 X-Git-Url: http://these/git/%24%7BgetStaticDir%28%29%7D/styles/%7BallRss%7D?a=commitdiff_plain;h=a4fddd6d7f540db903b698f66f965f2f1ab2fd5e;p=lemmy-ui.git Adding expandable post texts by clicking on book. Fixes #225 --- diff --git a/src/shared/components/post-listing.tsx b/src/shared/components/post-listing.tsx index 2c08597..c10a8dd 100644 --- a/src/shared/components/post-listing.tsx +++ b/src/shared/components/post-listing.tsx @@ -58,6 +58,7 @@ interface PostListingState { viewSource: boolean; showAdvanced: boolean; showMoreMobile: boolean; + showBody: boolean; my_vote: number; score: number; upvotes: number; @@ -91,6 +92,7 @@ export class PostListing extends Component { viewSource: false, showAdvanced: false, showMoreMobile: false, + showBody: false, my_vote: this.props.post_view.my_vote, score: this.props.post_view.counts.score, upvotes: this.props.post_view.counts.upvotes, @@ -146,10 +148,10 @@ export class PostListing extends Component { return (
- {post.url && this.props.showBody && post.embed_title && ( + {post.url && this.showBody && post.embed_title && ( )} - {this.props.showBody && + {this.showBody && post.body && (this.state.viewSource ? (
{post.body}
@@ -314,18 +316,16 @@ export class PostListing extends Component { <>
  • •
  • - {/* Using a link with tippy doesn't work on touch devices unfortunately */} - - +
  • )} @@ -373,7 +373,7 @@ export class PostListing extends Component { return (
    - {this.props.showBody && post.url ? ( + {this.showBody && post.url ? ( { )} - {!this.props.showBody && ( + {!this.showBody && ( - {!this.state.showMoreMobile && this.props.showBody && ( + {!this.state.showMoreMobile && this.showBody && ( ) : ( <> - {this.props.showBody && post_view.post.body && ( + {this.showBody && post_view.post.body && ( ))} {!post_view.creator_banned_from_community && ( - + )} )} {/* Community creators and admins can transfer community to another mod */} @@ -1015,7 +1015,7 @@ export class PostListing extends Component { let post = this.props.post_view.post; return ( post.body && - !this.props.showBody && ( + !this.showBody && (
    { return params; } + get showBody(): boolean { + return this.props.showBody || this.state.showBody; + } + handleModRemoveShow(i: PostListing) { i.state.showRemoveDialog = true; i.setState(i.state); @@ -1495,6 +1499,12 @@ export class PostListing extends Component { setupTippy(); } + handleShowBody(i: PostListing) { + i.state.showBody = !i.state.showBody; + i.setState(i.state); + setupTippy(); + } + get pointsTippy(): string { let points = i18n.t("number_of_points", { count: this.state.score,