From cb1b56f5a0eddbf77446f415f2beda57c8305f85 Mon Sep 17 00:00:00 2001 From: polwex Date: Sun, 23 Nov 2025 01:12:53 +0700 Subject: wut --- packages/tweetdeck/src/components/ChatCard.tsx | 56 ++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 packages/tweetdeck/src/components/ChatCard.tsx (limited to 'packages/tweetdeck/src/components/ChatCard.tsx') diff --git a/packages/tweetdeck/src/components/ChatCard.tsx b/packages/tweetdeck/src/components/ChatCard.tsx new file mode 100644 index 0000000..d7d885c --- /dev/null +++ b/packages/tweetdeck/src/components/ChatCard.tsx @@ -0,0 +1,56 @@ +import type { TwitterNotification } from "../lib/fetching/types"; +import { timeAgo } from "../lib/utils/time"; + +interface ChatCardProps { + notification: TwitterNotification; + accent: string; +} + +export function ChatCard({ notification, accent }: ChatCardProps) { + const firstUser = Object.values(notification.users)[0]; + const timestamp = timeAgo(Number(notification.timestampMs)); + + return ( +
+
+ {firstUser?.profile_image_url_https ? ( + {firstUser.name} + ) : ( + {firstUser?.name?.[0] ?? "?"} + )} +
+
+
+ {firstUser?.name ?? "Notification"} + {firstUser?.screen_name && @{firstUser.screen_name}} + + {timestamp} +
+

{highlight(notification.message.text)}

+
+
+ ); +} + +function highlight(text: string) { + const parts = text.split(/([@#][A-Za-z0-9_]+)/g); + return parts.map((part, index) => { + if (part.startsWith("@")) { + return ( + + {part} + + ); + } + if (part.startsWith("#")) { + return ( + + {part} + + ); + } + return {part}; + }); +} -- cgit v1.2.3