blob: 7658bfb8b0ab12c5f769157358ad4965f34c9a61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import { date_diff } from "@/logic/utils";
import type { PostProps } from "./Post";
import { useLocation } from "wouter";
function Header(props: PostProps) {
const [_, navigate] = useLocation();
function go(e: React.MouseEvent) {
e.stopPropagation();
}
function openThread(e: React.MouseEvent) {
e.stopPropagation();
const sel = window.getSelection()?.toString();
if (!sel) navigate(`/feed/${poast.host}/${poast.id}`);
}
const { poast } = props;
const name = (
<div className="name cp">
<p className="p-only">{poast.author}</p>
</div>
);
return (
<header>
<div className="author flex-align" role="link" onMouseUp={go}>
{name}
</div>
<div role="link" onMouseUp={openThread} className="date">
<p title={new Date(poast.time).toLocaleString()}>
{date_diff(poast.time, "short")}
</p>
</div>
</header>
);
}
export default Header;
|