Skip to content

Commit b661a03

Browse files
committed
Visually distinguish shared posts from normal ones
Close #111
1 parent 20f243d commit b661a03

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ To be released.
1010
available theme colors can be found in the [*Colors* section] of the Pico
1111
CSS docs.
1212

13+
- On profile page, shared posts are now more visually separated from the
14+
original posts, and the time of sharing is now shown. [[#111]]
15+
1316
- On profile page, alt texts for images are now expanded within `<details>`.
1417
[[#99], [#110] by Okuto Oyama]
1518

1619
[*Colors* section]: https://picocss.com/docs/colors
1720
[#110]: https://github.com/fedify-dev/hollo/pull/110
21+
[#111]: https://github.com/fedify-dev/hollo/issues/111
1822

1923

2024
Version 0.5.2

src/components/Post.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,19 @@ export interface PostProps {
4343
| null;
4444
reactions: Reaction[];
4545
};
46+
readonly shared?: Date;
4647
readonly pinned?: boolean;
4748
readonly quoted?: boolean;
4849
}
4950

50-
export function Post({ post, pinned, quoted }: PostProps) {
51+
export function Post({ post, shared, pinned, quoted }: PostProps) {
5152
if (post.sharing != null)
52-
return <Post post={{ ...post.sharing, sharing: null }} />;
53+
return (
54+
<Post
55+
post={{ ...post.sharing, sharing: null }}
56+
shared={post.published ?? undefined}
57+
/>
58+
);
5359
const account = post.account;
5460
const authorNameHtml = renderCustomEmojis(account.name, account.emojis);
5561
const authorUrl = account.url ?? account.iri;
@@ -110,10 +116,26 @@ export function Post({ post, pinned, quoted }: PostProps) {
110116
)}
111117
<footer>
112118
<p>
119+
{shared != null && (
120+
<small>
121+
Shared at{" "}
122+
<time dateTime={shared.toISOString()}>
123+
{shared.toLocaleString("en", {
124+
dateStyle: "medium",
125+
timeStyle: "short",
126+
})}
127+
</time>{" "}
128+
&middot;{" "}
129+
</small>
130+
)}
113131
<a href={post.url ?? post.iri}>
114132
<small>
133+
Published at{" "}
115134
<time dateTime={(post.published ?? post.updated).toISOString()}>
116-
{(post.published ?? post.updated).toLocaleString()}
135+
{(post.published ?? post.updated).toLocaleString("en", {
136+
dateStyle: "medium",
137+
timeStyle: "short",
138+
})}
117139
</time>
118140
</small>
119141
</a>

0 commit comments

Comments
 (0)