mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-29 15:51:14 +00:00
feat(post): Move post domain beneath post title (#1363)
* feat(post): Move post domain and preview button beneath post title * fix: Move the 'show body' button back to actions line; only show if there is something to show; add 'active' color * fix: Fix some margins
This commit is contained in:
parent
44c2d8ad5e
commit
94274a1e7f
2 changed files with 127 additions and 108 deletions
|
@ -84,10 +84,6 @@
|
||||||
margin-top: -6.5px;
|
margin-top: -6.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-title {
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-title a:visited {
|
.post-title a:visited {
|
||||||
color: var(--gray) !important;
|
color: var(--gray) !important;
|
||||||
}
|
}
|
||||||
|
|
|
@ -367,10 +367,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
|
|
||||||
createdLine() {
|
createdLine() {
|
||||||
const post_view = this.postView;
|
const post_view = this.postView;
|
||||||
const url = post_view.post.url;
|
|
||||||
const body = post_view.post.body;
|
|
||||||
return (
|
return (
|
||||||
<ul className="list-inline mb-1 text-muted small">
|
<ul className="list-inline mb-1 text-muted small mt-2">
|
||||||
<li className="list-inline-item">
|
<li className="list-inline-item">
|
||||||
<PersonListing person={post_view.creator} />
|
<PersonListing person={post_view.creator} />
|
||||||
|
|
||||||
|
@ -402,21 +400,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
<li className="list-inline-item">•</li>
|
<li className="list-inline-item">•</li>
|
||||||
{url && !(hostname(url) === getExternalHost()) && (
|
|
||||||
<>
|
|
||||||
<li className="list-inline-item">
|
|
||||||
<a
|
|
||||||
className="text-muted font-italic"
|
|
||||||
href={url}
|
|
||||||
title={url}
|
|
||||||
rel={relTags}
|
|
||||||
>
|
|
||||||
{hostname(url)}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li className="list-inline-item">•</li>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<li className="list-inline-item">
|
<li className="list-inline-item">
|
||||||
<span>
|
<span>
|
||||||
<MomentTime
|
<MomentTime
|
||||||
|
@ -425,21 +408,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
{body && (
|
|
||||||
<>
|
|
||||||
<li className="list-inline-item">•</li>
|
|
||||||
<li className="list-inline-item">
|
|
||||||
<button
|
|
||||||
className="text-muted btn btn-sm btn-link p-0"
|
|
||||||
data-tippy-content={mdNoImages.render(body)}
|
|
||||||
data-tippy-allowHtml={true}
|
|
||||||
onClick={linkEvent(this, this.handleShowBody)}
|
|
||||||
>
|
|
||||||
<Icon icon="book-open" classes="icon-inline mr-1" />
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</ul>
|
</ul>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -518,6 +486,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
const url = post.url;
|
const url = post.url;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<div className="post-title overflow-hidden">
|
<div className="post-title overflow-hidden">
|
||||||
<h5 className="d-inline">
|
<h5 className="d-inline">
|
||||||
{url && this.props.showBody ? (
|
{url && this.props.showBody ? (
|
||||||
|
@ -589,9 +558,33 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
{post.nsfw && (
|
{post.nsfw && (
|
||||||
<small className="ml-2 badge text-bg-danger">{i18n.t("nsfw")}</small>
|
<small className="ml-2 badge text-bg-danger">
|
||||||
|
{i18n.t("nsfw")}
|
||||||
|
</small>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{url && this.urlLine()}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
urlLine() {
|
||||||
|
const post = this.postView.post;
|
||||||
|
const url = post.url;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<p className="d-flex text-muted align-items-center gap-1 small m-0">
|
||||||
|
{url && !(hostname(url) === getExternalHost()) && (
|
||||||
|
<a
|
||||||
|
className="text-muted font-italic"
|
||||||
|
href={url}
|
||||||
|
title={url}
|
||||||
|
rel={relTags}
|
||||||
|
>
|
||||||
|
{hostname(url)}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,15 +653,45 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showPreviewButton() {
|
||||||
|
const post_view = this.postView;
|
||||||
|
const body = post_view.post.body;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
className="btn btn-link btn-animate text-muted py-0"
|
||||||
|
data-tippy-content={body && mdNoImages.render(body)}
|
||||||
|
data-tippy-allowHtml={true}
|
||||||
|
onClick={linkEvent(this, this.handleShowBody)}
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
icon="book-open"
|
||||||
|
classes={classNames("icon-inline mr-1", {
|
||||||
|
"text-success": this.state.showBody,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
postActions() {
|
postActions() {
|
||||||
// Possible enhancement: Priority+ pattern instead of just hard coding which get hidden behind the show more button.
|
// Possible enhancement: Priority+ pattern instead of just hard coding which get hidden behind the show more button.
|
||||||
// Possible enhancement: Make each button a component.
|
// Possible enhancement: Make each button a component.
|
||||||
const post_view = this.postView;
|
const post_view = this.postView;
|
||||||
|
const post = post_view.post;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{this.saveButton}
|
{this.saveButton}
|
||||||
{this.crossPostButton}
|
{this.crossPostButton}
|
||||||
|
|
||||||
|
{/**
|
||||||
|
* If there is a URL, or if the post has a body and we were told not to
|
||||||
|
* show the body, show the MetadataCard/body toggle.
|
||||||
|
*/}
|
||||||
|
{(post.url || (post.body && !this.props.showBody)) &&
|
||||||
|
this.showPreviewButton()}
|
||||||
|
|
||||||
{this.showBody && post_view.post.body && this.viewSourceButton}
|
{this.showBody && post_view.post.body && this.viewSourceButton}
|
||||||
|
|
||||||
{this.hasAdvancedButtons && (
|
{this.hasAdvancedButtons && (
|
||||||
|
|
Loading…
Reference in a new issue