55 HandThumbUpIcon ,
66 StopIcon ,
77} from "@heroicons/react/20/solid" ;
8+ import { cn } from "~/utils/cn" ;
89import { type FeedbackComment , KapaProvider , type QA , useChat } from "@kapaai/react-sdk" ;
910import { useSearchParams } from "@remix-run/react" ;
1011import DOMPurify from "dompurify" ;
@@ -37,7 +38,7 @@ function useKapaWebsiteId() {
3738 return routeMatch ?. kapa . websiteId ;
3839}
3940
40- export function AskAI ( ) {
41+ export function AskAI ( { isCollapsed = false } : { isCollapsed ?: boolean } ) {
4142 const { isManagedCloud } = useFeatures ( ) ;
4243 const websiteId = useKapaWebsiteId ( ) ;
4344
@@ -54,21 +55,23 @@ export function AskAI() {
5455 hideShortcutKey
5556 data-modal-override-open-class-ask-ai = "true"
5657 disabled
58+ className = { isCollapsed ? "w-full justify-center" : "" }
5759 >
5860 < AISparkleIcon className = "size-5" />
5961 </ Button >
6062 }
6163 >
62- { ( ) => < AskAIProvider websiteId = { websiteId } /> }
64+ { ( ) => < AskAIProvider websiteId = { websiteId } isCollapsed = { isCollapsed } /> }
6365 </ ClientOnly >
6466 ) ;
6567}
6668
6769type AskAIProviderProps = {
6870 websiteId : string ;
71+ isCollapsed ?: boolean ;
6972} ;
7073
71- function AskAIProvider ( { websiteId } : AskAIProviderProps ) {
74+ function AskAIProvider ( { websiteId, isCollapsed = false } : AskAIProviderProps ) {
7275 const [ isOpen , setIsOpen ] = useState ( false ) ;
7376 const [ initialQuery , setInitialQuery ] = useState < string | undefined > ( ) ;
7477 const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
@@ -112,28 +115,38 @@ function AskAIProvider({ websiteId }: AskAIProviderProps) {
112115 } }
113116 botProtectionMechanism = "hcaptcha"
114117 >
115- < TooltipProvider disableHoverableContent >
116- < Tooltip >
117- < TooltipTrigger asChild >
118- < div className = "inline-flex" >
119- < Button
120- variant = "small-menu-item"
121- data-action = "ask-ai"
122- shortcut = { { modifiers : [ "mod" ] , key : "/" , enabledOnInputElements : true } }
123- hideShortcutKey
124- data-modal-override-open-class-ask-ai = "true"
125- onClick = { ( ) => openAskAI ( ) }
126- >
127- < AISparkleIcon className = "size-5" />
128- </ Button >
118+ < motion . div layout = "position" transition = { { duration : 0.2 , ease : "easeInOut" } } >
119+ < TooltipProvider disableHoverableContent >
120+ < Tooltip >
121+ < div className = { isCollapsed ? "w-full" : "inline-flex" } >
122+ < TooltipTrigger asChild >
123+ < Button
124+ variant = "small-menu-item"
125+ data-action = "ask-ai"
126+ shortcut = { { modifiers : [ "mod" ] , key : "/" , enabledOnInputElements : true } }
127+ hideShortcutKey
128+ data-modal-override-open-class-ask-ai = "true"
129+ onClick = { ( ) => openAskAI ( ) }
130+ className = { isCollapsed ? "w-full justify-center" : "" }
131+ >
132+ < AISparkleIcon className = "size-5" />
133+ </ Button >
134+ </ TooltipTrigger >
129135 </ div >
130- </ TooltipTrigger >
131- < TooltipContent side = "top" className = "flex items-center gap-1 py-1.5 pl-2.5 pr-2 text-xs" >
132- Ask AI
133- < ShortcutKey shortcut = { { modifiers : [ "mod" ] , key : "/" } } variant = "medium/bright" />
134- </ TooltipContent >
135- </ Tooltip >
136- </ TooltipProvider >
136+ < TooltipContent
137+ side = { isCollapsed ? "right" : "top" }
138+ sideOffset = { isCollapsed ? 8 : 4 }
139+ className = "flex items-center gap-1 py-1.5 pl-2.5 pr-2 text-xs"
140+ >
141+ Ask AI
142+ < span className = "flex items-center" >
143+ < ShortcutKey shortcut = { { modifiers : [ "mod" ] } } variant = "medium/bright" />
144+ < ShortcutKey shortcut = { { key : "/" } } variant = "medium/bright" />
145+ </ span >
146+ </ TooltipContent >
147+ </ Tooltip >
148+ </ TooltipProvider >
149+ </ motion . div >
137150 < AskAIDialog
138151 initialQuery = { initialQuery }
139152 isOpen = { isOpen }
0 commit comments