@@ -47,36 +47,31 @@ export function AskAI({ isCollapsed = false }: { isCollapsed?: boolean }) {
4747 }
4848
4949 return (
50- < div
51- className = { cn (
52- "transition-opacity duration-200" ,
53- isCollapsed ? "pointer-events-none opacity-0" : "opacity-100"
54- ) }
50+ < ClientOnly
51+ fallback = {
52+ < Button
53+ variant = "small-menu-item"
54+ data-action = "ask-ai"
55+ hideShortcutKey
56+ data-modal-override-open-class-ask-ai = "true"
57+ disabled
58+ className = { isCollapsed ? "w-full justify-center" : "" }
59+ >
60+ < AISparkleIcon className = "size-5" />
61+ </ Button >
62+ }
5563 >
56- < ClientOnly
57- fallback = {
58- < Button
59- variant = "small-menu-item"
60- data-action = "ask-ai"
61- hideShortcutKey
62- data-modal-override-open-class-ask-ai = "true"
63- disabled
64- >
65- < AISparkleIcon className = "size-5" />
66- </ Button >
67- }
68- >
69- { ( ) => < AskAIProvider websiteId = { websiteId } /> }
70- </ ClientOnly >
71- </ div >
64+ { ( ) => < AskAIProvider websiteId = { websiteId } isCollapsed = { isCollapsed } /> }
65+ </ ClientOnly >
7266 ) ;
7367}
7468
7569type AskAIProviderProps = {
7670 websiteId : string ;
71+ isCollapsed ?: boolean ;
7772} ;
7873
79- function AskAIProvider ( { websiteId } : AskAIProviderProps ) {
74+ function AskAIProvider ( { websiteId, isCollapsed = false } : AskAIProviderProps ) {
8075 const [ isOpen , setIsOpen ] = useState ( false ) ;
8176 const [ initialQuery , setInitialQuery ] = useState < string | undefined > ( ) ;
8277 const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
@@ -120,28 +115,38 @@ function AskAIProvider({ websiteId }: AskAIProviderProps) {
120115 } }
121116 botProtectionMechanism = "hcaptcha"
122117 >
123- < TooltipProvider disableHoverableContent >
124- < Tooltip >
125- < TooltipTrigger asChild >
126- < div className = "inline-flex" >
127- < Button
128- variant = "small-menu-item"
129- data-action = "ask-ai"
130- shortcut = { { modifiers : [ "mod" ] , key : "/" , enabledOnInputElements : true } }
131- hideShortcutKey
132- data-modal-override-open-class-ask-ai = "true"
133- onClick = { ( ) => openAskAI ( ) }
134- >
135- < AISparkleIcon className = "size-5" />
136- </ Button >
137- </ div >
138- </ TooltipTrigger >
139- < TooltipContent side = "top" className = "flex items-center gap-1 py-1.5 pl-2.5 pr-2 text-xs" >
140- Ask AI
141- < ShortcutKey shortcut = { { modifiers : [ "mod" ] , key : "/" } } variant = "medium/bright" />
142- </ TooltipContent >
143- </ Tooltip >
144- </ TooltipProvider >
118+ < motion . div layout = "position" transition = { { duration : 0.2 , ease : "easeInOut" } } >
119+ < TooltipProvider disableHoverableContent >
120+ < Tooltip >
121+ < TooltipTrigger asChild >
122+ < div className = { isCollapsed ? "w-full" : "inline-flex" } >
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+ </ div >
135+ </ TooltipTrigger >
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 >
145150 < AskAIDialog
146151 initialQuery = { initialQuery }
147152 isOpen = { isOpen }
0 commit comments