diff options
author | polwex <polwex@sortug.com> | 2025-09-11 01:48:14 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-09-11 01:48:14 +0700 |
commit | b1d68ac307ed87d63e83820cbdf843fff0fd9f7f (patch) | |
tree | d6a684a70a80509e68ff667b842aa4e4c091906f /front/src/components/feed/Header.tsx |
init
Diffstat (limited to 'front/src/components/feed/Header.tsx')
-rw-r--r-- | front/src/components/feed/Header.tsx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/front/src/components/feed/Header.tsx b/front/src/components/feed/Header.tsx new file mode 100644 index 0000000..7658bfb --- /dev/null +++ b/front/src/components/feed/Header.tsx @@ -0,0 +1,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; |