From 45779a980eff848a480a668a8b28a83b5bc25d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Mon, 25 Aug 2025 09:36:33 +0200 Subject: [PATCH 01/11] Improve it for all --- .../gitbook/src/components/AIChat/AIChat.tsx | 48 ++++++---- .../Embeddable/EmbeddableAIChat.tsx | 25 ++++- .../Embeddable/EmbeddableDocsPage.tsx | 42 +++++++-- .../components/Embeddable/EmbeddableFrame.tsx | 94 +++++++++++++------ .../Embeddable/EmbeddableIframeAPI.tsx | 10 ++ .../Embeddable/EmbeddableRootLayout.tsx | 32 +++---- 6 files changed, 174 insertions(+), 77 deletions(-) diff --git a/packages/gitbook/src/components/AIChat/AIChat.tsx b/packages/gitbook/src/components/AIChat/AIChat.tsx index b1b00c449b..2d7bfde8c3 100644 --- a/packages/gitbook/src/components/AIChat/AIChat.tsx +++ b/packages/gitbook/src/components/AIChat/AIChat.tsx @@ -11,7 +11,15 @@ import { useAIChatController, useAIChatState, } from '../AI'; -import { EmbeddableFrame } from '../Embeddable/EmbeddableFrame'; +import { + EmbeddableFrame, + EmbeddableFrameBody, + EmbeddableFrameButtons, + EmbeddableFrameHeader, + EmbeddableFrameHeaderMain, + EmbeddableFrameSubtitle, + EmbeddableFrameTitle, +} from '../Embeddable/EmbeddableFrame'; import { useNow } from '../hooks'; import { Button } from '../primitives'; import { DropdownMenu, DropdownMenuItem } from '../primitives'; @@ -66,19 +74,22 @@ export function AIChat(props: { trademark: boolean }) { data-testid="ai-chat" className="ai-chat inset-y-0 right-0 z-40 mx-auto flex max-w-3xl animate-present scroll-mt-36 px-4 py-4 transition-all duration-300 sm:px-6 lg:fixed lg:w-80 lg:animate-enter-from-right lg:pr-4 lg:pl-0 xl:w-96" > - } - title={getAIChatName(language, trademark)} - subtitle={ - chat.loading - ? chat.messages[chat.messages.length - 1].content - ? tString(language, 'ai_chat_working') - : tString(language, 'ai_chat_thinking') - : '' - } - buttons={ - <> + + + + + + {getAIChatName(language, trademark)} + + + {chat.messages[chat.messages.length - 1].content + ? tString(language, 'ai_chat_working') + : tString(language, 'ai_chat_thinking')} + + + {chat.messages.length > 0 ? ( - - } - > - + + + + + ); diff --git a/packages/gitbook/src/components/Embeddable/EmbeddableAIChat.tsx b/packages/gitbook/src/components/Embeddable/EmbeddableAIChat.tsx index f050a0b640..83b415b895 100644 --- a/packages/gitbook/src/components/Embeddable/EmbeddableAIChat.tsx +++ b/packages/gitbook/src/components/Embeddable/EmbeddableAIChat.tsx @@ -1,7 +1,15 @@ 'use client'; import { useAIChatController, useAIChatState } from '@/components/AI'; -import { AIChatBody } from '@/components/AIChat'; +import { AIChatBody, AIChatDynamicIcon } from '@/components/AIChat'; +import { + EmbeddableFrame, + EmbeddableFrameBody, + EmbeddableFrameHeader, + EmbeddableFrameHeaderMain, + EmbeddableFrameTitle, +} from './EmbeddableFrame'; +import { EmbeddableIframeButtons } from './EmbeddableIframeAPI'; /** * Embeddable AI chat window in an iframe. @@ -13,5 +21,18 @@ export function EmbeddableAIChat(props: { const chat = useAIChatState(); const chatController = useAIChatController(); - return ; + return ( + + + + + Chat with us + + + + + + + + ); } diff --git a/packages/gitbook/src/components/Embeddable/EmbeddableDocsPage.tsx b/packages/gitbook/src/components/Embeddable/EmbeddableDocsPage.tsx index c481363e02..fa9cec3cc5 100644 --- a/packages/gitbook/src/components/Embeddable/EmbeddableDocsPage.tsx +++ b/packages/gitbook/src/components/Embeddable/EmbeddableDocsPage.tsx @@ -3,6 +3,14 @@ import { type PagePathParams, getSitePageData } from '@/components/SitePage'; import { PageBody } from '@/components/PageBody'; import type { GitBookSiteContext } from '@/lib/context'; import type { Metadata } from 'next'; +import { Button } from '../primitives'; +import { + EmbeddableFrame, + EmbeddableFrameBody, + EmbeddableFrameHeader, + EmbeddableFrameHeaderMain, +} from './EmbeddableFrame'; +import { EmbeddableIframeButtons } from './EmbeddableIframeAPI'; export const dynamic = 'force-static'; @@ -22,15 +30,31 @@ export async function EmbeddableDocsPage(props: EmbeddableDocsPageProps) { }); return ( -
- -
+ + + +