From 4c34ab833c6ea1cd34d89d933a37f55d454df7e0 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Tue, 10 Jun 2025 02:52:41 +0100 Subject: [PATCH] Add chat header buttons --- .../FrameRenderer/RoadmapFloatingChat.tsx | 104 ++++++++++++++++-- 1 file changed, 97 insertions(+), 7 deletions(-) diff --git a/src/components/FrameRenderer/RoadmapFloatingChat.tsx b/src/components/FrameRenderer/RoadmapFloatingChat.tsx index 3c552c4b2..4e34f8aac 100644 --- a/src/components/FrameRenderer/RoadmapFloatingChat.tsx +++ b/src/components/FrameRenderer/RoadmapFloatingChat.tsx @@ -1,10 +1,14 @@ import { useQuery } from '@tanstack/react-query'; import type { JSONContent } from '@tiptap/core'; import { + AppWindow, + BookOpen, MessageCirclePlus, PauseCircleIcon, SendIcon, + Trash2, Wand2, + X, } from 'lucide-react'; import { Fragment, useEffect, useMemo, useRef, useState } from 'react'; import { flushSync } from 'react-dom'; @@ -20,6 +24,54 @@ import { roadmapJSONOptions } from '../../queries/roadmap'; import { queryClient } from '../../stores/query-client'; import { RoadmapAIChatCard } from '../RoadmapAIChat/RoadmapAIChatCard'; +type ChatHeaderButtonProps = { + onClick?: () => void; + href?: string; + icon: React.ReactNode; + children?: React.ReactNode; + className?: string; + target?: string; +}; + +function ChatHeaderButton(props: ChatHeaderButtonProps) { + const { onClick, href, icon, children, className, target } = props; + + const classNames = cn( + 'flex items-center gap-1.5 text-xs text-gray-600 transition-colors hover:text-gray-900', + className, + ); + + if (!onClick && !href) { + return ( + + {icon} + {children && {children}} + + ); + } + + if (href) { + return ( + + {icon} + {children && {children}} + + ); + } + + return ( + + ); +} + type RoadmapChatProps = { roadmapId: string; }; @@ -70,6 +122,7 @@ export function RoadmapFloatingChat(props: RoadmapChatProps) { handleChatSubmit, handleAbort, scrollToBottom, + clearChat, } = useRoadmapAIChat({ roadmapId, totalTopicCount, @@ -123,12 +176,52 @@ export function RoadmapFloatingChat(props: RoadmapChatProps) { > )} -
+
{isOpen && (
{/* Messages area */} +
+ }> + AI Tutor + + +
+ {hasMessages && ( + { + setInputValue(''); + clearChat(); + }} + icon={} + className="mr-2 text-gray-500" + > + Clear + + )} + + } + className="rounded-md bg-gray-200 py-1 pr-2 pl-1.5 text-gray-500 hover:bg-gray-300" + > + Open in new tab + + + setIsOpen(false)} + icon={} + className="rounded-md bg-red-100 px-1 py-1 text-red-500 hover:bg-red-200" + /> +
+
@@ -204,8 +297,7 @@ export function RoadmapFloatingChat(props: RoadmapChatProps) { {!isOpen && (