mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-30 00:01:15 +00:00
parent
b77689ebd1
commit
321339c6c5
5 changed files with 12 additions and 30 deletions
|
@ -374,3 +374,11 @@ br.big {
|
||||||
.slight-radius {
|
.slight-radius {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.preview-lines {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import {
|
||||||
isMod,
|
isMod,
|
||||||
mdToHtml,
|
mdToHtml,
|
||||||
numToSI,
|
numToSI,
|
||||||
previewLines,
|
|
||||||
relTags,
|
relTags,
|
||||||
restoreScrollPosition,
|
restoreScrollPosition,
|
||||||
routeSortTypeToEnum,
|
routeSortTypeToEnum,
|
||||||
|
@ -221,7 +220,7 @@ export class Profile extends Component<any, ProfileState> {
|
||||||
|
|
||||||
get bioTag(): string {
|
get bioTag(): string {
|
||||||
return this.state.personRes.person_view.person.bio
|
return this.state.personRes.person_view.person.bio
|
||||||
? previewLines(this.state.personRes.person_view.person.bio)
|
? this.state.personRes.person_view.person.bio
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ import {
|
||||||
md,
|
md,
|
||||||
mdToHtml,
|
mdToHtml,
|
||||||
numToSI,
|
numToSI,
|
||||||
previewLines,
|
|
||||||
relTags,
|
relTags,
|
||||||
setupTippy,
|
setupTippy,
|
||||||
showScores,
|
showScores,
|
||||||
|
@ -355,9 +354,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
<li className="list-inline-item">
|
<li className="list-inline-item">
|
||||||
<button
|
<button
|
||||||
className="text-muted btn btn-sm btn-link p-0"
|
className="text-muted btn btn-sm btn-link p-0"
|
||||||
data-tippy-content={md.render(
|
data-tippy-content={md.render(post_view.post.body)}
|
||||||
previewLines(post_view.post.body)
|
|
||||||
)}
|
|
||||||
data-tippy-allowHtml={true}
|
data-tippy-allowHtml={true}
|
||||||
onClick={linkEvent(this, this.handleShowBody)}
|
onClick={linkEvent(this, this.handleShowBody)}
|
||||||
>
|
>
|
||||||
|
@ -1093,12 +1090,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
return (
|
return (
|
||||||
post.body &&
|
post.body &&
|
||||||
!this.showBody && (
|
!this.showBody && (
|
||||||
<div
|
<div className="md-div mb-1 preview-lines">{post.body}</div>
|
||||||
className="md-div mb-1"
|
|
||||||
dangerouslySetInnerHTML={{
|
|
||||||
__html: md.render(previewLines(post.body)),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@ import {
|
||||||
insertCommentIntoTree,
|
insertCommentIntoTree,
|
||||||
isBrowser,
|
isBrowser,
|
||||||
isImage,
|
isImage,
|
||||||
previewLines,
|
|
||||||
restoreScrollPosition,
|
restoreScrollPosition,
|
||||||
saveCommentRes,
|
saveCommentRes,
|
||||||
saveScrollPosition,
|
saveScrollPosition,
|
||||||
|
@ -287,8 +286,7 @@ export class Post extends Component<any, PostState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
get descriptionTag(): string {
|
get descriptionTag(): string {
|
||||||
let body = this.state.postRes.post_view.post.body;
|
return this.state.postRes.post_view.post.body;
|
||||||
return body ? previewLines(body) : undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -1034,21 +1034,6 @@ function hsl(num: number) {
|
||||||
return `hsla(${num}, 35%, 50%, 1)`;
|
return `hsla(${num}, 35%, 50%, 1)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function previewLines(
|
|
||||||
text: string,
|
|
||||||
maxChars = 300,
|
|
||||||
maxLines = 1
|
|
||||||
): string {
|
|
||||||
return (
|
|
||||||
text
|
|
||||||
.slice(0, maxChars)
|
|
||||||
.split("\n")
|
|
||||||
// Use lines * 2 because markdown requires 2 lines
|
|
||||||
.slice(0, maxLines * 2)
|
|
||||||
.join("\n") + "..."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function hostname(url: string): string {
|
export function hostname(url: string): string {
|
||||||
let cUrl = new URL(url);
|
let cUrl = new URL(url);
|
||||||
return cUrl.port ? `${cUrl.hostname}:${cUrl.port}` : `${cUrl.hostname}`;
|
return cUrl.port ? `${cUrl.hostname}:${cUrl.port}` : `${cUrl.hostname}`;
|
||||||
|
|
Loading…
Reference in a new issue