From d9ad044ecdecab4b9fb9523b3dedccd35587ae8f Mon Sep 17 00:00:00 2001 From: Dan Ditomaso Date: Wed, 29 Jan 2025 16:08:55 -0500 Subject: [PATCH] fix: improve styling of messsges --- .../PageComponents/Messages/ChannelChat.tsx | 96 ++++++++++--------- .../PageComponents/Messages/Message.tsx | 89 +++++++++-------- .../PageComponents/Messages/MessageInput.tsx | 2 +- src/components/UI/Footer.tsx | 2 +- src/components/UI/Sidebar/sidebarButton.tsx | 5 +- 5 files changed, 100 insertions(+), 94 deletions(-) diff --git a/src/components/PageComponents/Messages/ChannelChat.tsx b/src/components/PageComponents/Messages/ChannelChat.tsx index 79950bf8..0771df04 100644 --- a/src/components/PageComponents/Messages/ChannelChat.tsx +++ b/src/components/PageComponents/Messages/ChannelChat.tsx @@ -8,6 +8,7 @@ import { MessageInput } from "@components/PageComponents/Messages/MessageInput.t import { TraceRoute } from "@components/PageComponents/Messages/TraceRoute.tsx"; import type { Protobuf, Types } from "@meshtastic/js"; import { InboxIcon } from "lucide-react"; +import type { JSX } from "react"; export interface ChannelChatProps { messages?: MessageWithState[]; @@ -16,6 +17,13 @@ export interface ChannelChatProps { traceroutes?: Types.PacketMetadata[]; } +const EmptyState = () => ( +
+ + No Messages +
+); + export const ChannelChat = ({ messages, channel, @@ -24,53 +32,53 @@ export const ChannelChat = ({ }: ChannelChatProps): JSX.Element => { const { nodes } = useDevice(); + if (!messages?.length) { + return ( + <> +
+ +
+
+ +
+ + ); + } + return ( -
-
-
- {messages ? ( - messages.map((message, index) => ( - - )) - ) : ( -
- - No Messages -
- )} + <> +
+
+ {messages.map((message, index) => ( + 0 && messages[index - 1].from === message.from + } + sender={nodes.get(message.from)} + /> + ))}
-
- {to === "broadcast" ? null : traceroutes ? ( - traceroutes.map((traceroute, index) => ( - - )) - ) : ( -
- - No Traceroutes -
- )} +
+
-
- -
-
+ {/* {to === "broadcast" ? null : traceroutes ? ( + traceroutes.map((traceroute, index) => ( + + )) + ) : ( +
+ + No Traceroutes +
+ )} */} + ); }; diff --git a/src/components/PageComponents/Messages/Message.tsx b/src/components/PageComponents/Messages/Message.tsx index e8030e2a..82312079 100644 --- a/src/components/PageComponents/Messages/Message.tsx +++ b/src/components/PageComponents/Messages/Message.tsx @@ -1,11 +1,7 @@ import type { MessageWithState } from "@app/core/stores/deviceStore.ts"; import { Avatar } from "@components/UI/Avatar"; import type { Protobuf } from "@meshtastic/js"; -import { - AlertCircleIcon, - CheckCircle2Icon, - CircleEllipsisIcon, -} from "lucide-react"; +import { AlertCircle, CheckCircle2, CircleEllipsis } from "lucide-react"; export interface MessageProps { lastMsgSameUser: boolean; @@ -13,61 +9,62 @@ export interface MessageProps { sender?: Protobuf.Mesh.NodeInfo; } +const StatusIcon = ({ state }: { state: MessageWithState["state"] }) => { + const iconClass = "text-gray-500 dark:text-gray-400 w-4 h-4"; + switch (state) { + case "ack": + return ; + case "waiting": + return ; + default: + return ; + } +}; + export const Message = ({ lastMsgSameUser, message, sender }: MessageProps) => { - return lastMsgSameUser ? ( -
- {message.state === "ack" ? ( - - ) : message.state === "waiting" ? ( - - ) : ( - - )} - - {message.data} - -
- ) : ( -
-
-
- + const messageTextClass = + message.state === "ack" + ? "text-gray-900 dark:text-white" + : "text-gray-500 dark:text-gray-400"; + if (lastMsgSameUser) { + return ( +
+
+
+ {message.data} +
+
- +
+ ); + } + + return ( +
+
+ + {sender?.user?.longName ?? "UNK"} - + {message.rxTime.toLocaleDateString()} - + {message.rxTime.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit", })}
-
- {message.state === "ack" ? ( - - ) : message.state === "waiting" ? ( - - ) : ( - - )} - +
{message.data} - +
+
); diff --git a/src/components/PageComponents/Messages/MessageInput.tsx b/src/components/PageComponents/Messages/MessageInput.tsx index ae88f9ac..079cb448 100644 --- a/src/components/PageComponents/Messages/MessageInput.tsx +++ b/src/components/PageComponents/Messages/MessageInput.tsx @@ -4,7 +4,7 @@ import { Input } from "@components/UI/Input.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; import type { Types } from "@meshtastic/js"; import { SendIcon } from "lucide-react"; -import { useCallback, useMemo, useState } from "react"; +import { type JSX, useCallback, useMemo, useState } from "react"; export interface MessageInputProps { to: Types.Destination; diff --git a/src/components/UI/Footer.tsx b/src/components/UI/Footer.tsx index d0e082e7..c50bb3e4 100644 --- a/src/components/UI/Footer.tsx +++ b/src/components/UI/Footer.tsx @@ -6,7 +6,7 @@ const Footer = React.forwardRef( ({ className, ...props }, ref) => { return (