From: Dessalines Date: Fri, 3 Apr 2020 17:46:25 +0000 (-0400) Subject: Adding a text body preview and icon for posts with a body. Fixes #617 X-Git-Url: http://these/git/%22%7Burl%7D/%7B%60%24%7BghostArchiveUrl%7D/static/gitweb.css?a=commitdiff_plain;h=0ca385deaf00d905081c66d0e0164558531e0e70;p=lemmy.git Adding a text body preview and icon for posts with a body. Fixes #617 --- diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index ff863dcb..101d1807 100644 --- a/ui/src/components/post-listing.tsx +++ b/ui/src/components/post-listing.tsx @@ -20,6 +20,7 @@ import { MomentTime } from './moment-time'; import { PostForm } from './post-form'; import { IFramelyCard } from './iframely-card'; import { + md, mdToHtml, canMod, isMod, @@ -30,6 +31,7 @@ import { showAvatars, pictshareImage, setupTippy, + previewLines, } from '../utils'; import { i18n } from '../i18next'; @@ -459,6 +461,24 @@ export class PostListing extends Component { + {post.body && ( + <> +
  • •
  • +
  • + {/* Using a link with tippy doesn't work on touch devices unfortunately */} + + + + + +
  • + + )}
  • •
  • {this.state.upvotes !== this.state.score && ( <> diff --git a/ui/src/components/symbols.tsx b/ui/src/components/symbols.tsx index 16deec3e..dae734a8 100644 --- a/ui/src/components/symbols.tsx +++ b/ui/src/components/symbols.tsx @@ -15,6 +15,9 @@ export class Symbols extends Component { xmlnsXlink="http://www.w3.org/1999/xlink" > + + + diff --git a/ui/src/utils.ts b/ui/src/utils.ts index 8ecef19b..d659509c 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -823,3 +823,11 @@ function hsl(num: number) { function randomHsl() { return `hsla(${Math.random() * 360}, 100%, 50%, 1)`; } + +export function previewLines(text: string, lines: number = 3): string { + // Use lines * 2 because markdown requires 2 lines + return text + .split('\n') + .slice(0, lines * 2) + .join('\n'); +}