From 94274a1e7fee63dd8a73e74e2e56a3517e3807d6 Mon Sep 17 00:00:00 2001
From: Jay Sitter
Date: Mon, 19 Jun 2023 11:26:29 -0400
Subject: [PATCH] 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
---
src/assets/css/main.css | 4 -
src/shared/components/post/post-listing.tsx | 231 +++++++++++---------
2 files changed, 127 insertions(+), 108 deletions(-)
diff --git a/src/assets/css/main.css b/src/assets/css/main.css
index da3f7ff..f9aa1ff 100644
--- a/src/assets/css/main.css
+++ b/src/assets/css/main.css
@@ -84,10 +84,6 @@
margin-top: -6.5px;
}
-.post-title {
- line-height: 1;
-}
-
.post-title a:visited {
color: var(--gray) !important;
}
diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx
index 80da4b3..48d2dc6 100644
--- a/src/shared/components/post/post-listing.tsx
+++ b/src/shared/components/post/post-listing.tsx
@@ -367,10 +367,8 @@ export class PostListing extends Component {
createdLine() {
const post_view = this.postView;
- const url = post_view.post.url;
- const body = post_view.post.body;
return (
-
+
@@ -402,21 +400,6 @@ export class PostListing extends Component {
)}
•
- {url && !(hostname(url) === getExternalHost()) && (
- <>
-
-
- {hostname(url)}
-
-
- •
- >
- )}
{
/>
- {body && (
- <>
- •
-
-
-
-
-
- >
- )}
);
}
@@ -518,80 +486,105 @@ export class PostListing extends Component {
const url = post.url;
return (
-
-
- {url && this.props.showBody ? (
-
- ) : (
- this.postLink
- )}
-
- {(url && isImage(url)) ||
- (post.thumbnail_url && (
-
-
+
+
+ {url && this.props.showBody ? (
+
-
- ))}
- {post.removed && (
-
- {i18n.t("removed")}
-
- )}
- {post.deleted && (
-
+ ) : (
+ this.postLink
+ )}
+
+ {(url && isImage(url)) ||
+ (post.thumbnail_url && (
+
+
+
+ ))}
+ {post.removed && (
+
+ {i18n.t("removed")}
+
+ )}
+ {post.deleted && (
+
+
+
+ )}
+ {post.locked && (
+
+
+
+ )}
+ {post.featured_community && (
+
+
+
+ )}
+ {post.featured_local && (
+
+
+
+ )}
+ {post.nsfw && (
+
+ {i18n.t("nsfw")}
+
+ )}
+
+ {url && this.urlLine()}
+ >
+ );
+ }
+
+ urlLine() {
+ const post = this.postView.post;
+ const url = post.url;
+
+ return (
+
+ {url && !(hostname(url) === getExternalHost()) && (
+
-
-
+ {hostname(url)}
+
)}
- {post.locked && (
-
-
-
- )}
- {post.featured_community && (
-
-
-
- )}
- {post.featured_local && (
-
-
-
- )}
- {post.nsfw && (
- {i18n.t("nsfw")}
- )}
-
+
);
}
@@ -660,15 +653,45 @@ export class PostListing extends Component {
);
}
+ showPreviewButton() {
+ const post_view = this.postView;
+ const body = post_view.post.body;
+
+ return (
+
+
+
+ );
+ }
+
postActions() {
// Possible enhancement: Priority+ pattern instead of just hard coding which get hidden behind the show more button.
// Possible enhancement: Make each button a component.
const post_view = this.postView;
+ const post = post_view.post;
+
return (
<>
{this.saveButton}
{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.hasAdvancedButtons && (