From df0bb733055f53b3ce9919d51d93ee93ec017eba Mon Sep 17 00:00:00 2001 From: Arthur Belleville Date: Thu, 19 Jun 2025 22:33:03 +0200 Subject: [PATCH] Improve chat view --- ui/src/App.tsx | 7 +- ui/src/components/Layout.tsx | 2 +- ui/src/components/NavigationBar.tsx | 2 +- ui/src/main.css | 9 ++ ui/src/main.tsx | 1 + ui/src/pages/chat.tsx | 242 ++++++++++++++++------------ 6 files changed, 152 insertions(+), 111 deletions(-) create mode 100644 ui/src/main.css diff --git a/ui/src/App.tsx b/ui/src/App.tsx index 451219e..af48b42 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -28,12 +28,7 @@ export const App = () => { -
+
}>
-
{children}
+
{children}
); } diff --git a/ui/src/components/NavigationBar.tsx b/ui/src/components/NavigationBar.tsx index 04cd68c..717a31d 100644 --- a/ui/src/components/NavigationBar.tsx +++ b/ui/src/components/NavigationBar.tsx @@ -277,7 +277,7 @@ export function MainNavigation({ isCollapsed }: { isCollapsed: boolean }) { }, { path: "/chat", - label: "Messages", + label: "Discussions", icon: , }, ]; diff --git a/ui/src/main.css b/ui/src/main.css new file mode 100644 index 0000000..45f7540 --- /dev/null +++ b/ui/src/main.css @@ -0,0 +1,9 @@ +/* .str-chat { + --str-chat__primary-color: #000; + --str-chat__active-primary-color: #000; + --str-chat__surface-color: #000; + --str-chat__secondary-surface-color: #000; + --str-chat__primary-surface-color: #000; + --str-chat__primary-surface-color-low-emphasis: #000; + --str-chat__border-radius-circle: 6px; +} */ diff --git a/ui/src/main.tsx b/ui/src/main.tsx index 7e800a5..f0d44aa 100644 --- a/ui/src/main.tsx +++ b/ui/src/main.tsx @@ -6,6 +6,7 @@ import { queryClient } from "./lib/api"; import { GlobalToastRegion } from "./ui-library/toast/toast-region"; import "stream-chat-react/dist/css/v2/index.css"; +import "./main.css"; createRoot(document.getElementById("root")!).render( diff --git a/ui/src/pages/chat.tsx b/ui/src/pages/chat.tsx index 7257a53..4d6af2e 100644 --- a/ui/src/pages/chat.tsx +++ b/ui/src/pages/chat.tsx @@ -1,134 +1,170 @@ import { useState } from "react"; import { - Channel, ChannelList, MessageList, MessageInput, Window, - Thread, - ChannelPreviewUIComponentProps, useChatContext, + SendButton, + Channel, + ChatView, + Thread, + ThreadList, + ChannelPreviewUIComponentProps, } from "stream-chat-react"; -export function ChatPage() { - const { client, channel: activeChannel, setActiveChannel } = useChatContext(); - const [creating, setCreating] = useState(false); - const [showSidebar, setShowSidebar] = useState(true); +interface ChannelData { + name?: string; + image?: string; + members?: string[]; +} - // Custom Preview component for ChannelList - const CustomChannelPreview = (props: ChannelPreviewUIComponentProps) => { - const { - channel, - activeChannel: currentActiveChannel, - setActiveChannel: setActive, - } = props; - const isSelected = channel?.id === currentActiveChannel?.id; - const channelName = - channel.data && "name" in channel.data ? channel.data.name : channel.id; - const lastMessage = channel.state?.messages?.length - ? channel.state.messages[channel.state.messages.length - 1]?.text - : undefined; - return ( - - ); - }; +export function ChatPage() { + const { client } = useChatContext(); + const [isCreating, setIsCreating] = useState(false); const handleCreateChannel = async () => { const name = window.prompt("Enter channel name:"); if (!name) return; - setCreating(true); + setIsCreating(true); try { - const newChannel = client.channel("messaging", name); + const channelData: ChannelData = { + name, + members: [client.userID || ""], + }; + const newChannel = client.channel("messaging", name, channelData); await newChannel.create(); - setActiveChannel(newChannel); - setShowSidebar(false); // Hide sidebar on mobile after creating channel } catch { alert("Failed to create channel"); } finally { - setCreating(false); + setIsCreating(false); } }; - // Responsive: show sidebar only if no channel is selected or on large screens - return ( -
- {/* Sidebar: hidden on mobile if a channel is selected */} - +
+ ); + }; - {/* Main Chat Area: takes full width if a channel is selected */} - {activeChannel ? ( -
- - - {/* Header with back button on mobile */} -
- -
- {activeChannel.data && - typeof activeChannel.data === "object" && - "name" in activeChannel.data - ? (activeChannel.data as { name?: string }).name || - activeChannel.id - : activeChannel.id} + const actions = [ + "delete", + "edit", + "flag", + "markUnread", + "mute", + "react", + "reply", + ]; + + return ( +
+ + +
+ +
+
+
+ + Discussions + + +
+
+
- - - - - +
+ + +
+
+
+
+ + # + +
+
+

+ Channel Name +

+

Active now

+
+
+
+ + +
+
+
+ + +
+
+
+
+
+
+
- ) : ( -
- Select a channel to start chatting -
- )} + + + + + + +
); }