1
1
'use client' ;
2
2
3
3
import { Fragment , useCallback , useEffect , useRef , useState } from 'react' ;
4
- import { ArrowRightIcon } from '@radix-ui/react-icons ' ;
4
+ import { Button } from '@radix-ui/themes ' ;
5
5
import { captureException } from '@sentry/nextjs' ;
6
6
import {
7
7
Hit ,
@@ -17,7 +17,6 @@ import {isDeveloperDocs} from 'sentry-docs/isDeveloperDocs';
17
17
18
18
import styles from './search.module.scss' ;
19
19
20
- import { MagicIcon } from '../cutomIcons/magic' ;
21
20
import { Logo } from '../logo' ;
22
21
23
22
import { SearchResultItems } from './searchResultItems' ;
@@ -62,9 +61,10 @@ type Props = {
62
61
autoFocus ?: boolean ;
63
62
path ?: string ;
64
63
searchPlatforms ?: string [ ] ;
64
+ showChatBot ?: boolean ;
65
65
} ;
66
66
67
- export function Search ( { path, autoFocus, searchPlatforms = [ ] } : Props ) {
67
+ export function Search ( { path, autoFocus, searchPlatforms = [ ] , showChatBot } : Props ) {
68
68
const ref = useRef < HTMLDivElement > ( null ) ;
69
69
const [ query , setQuery ] = useState ( `` ) ;
70
70
const [ results , setResults ] = useState ( [ ] as Result [ ] ) ;
@@ -235,7 +235,7 @@ export function Search({path, autoFocus, searchPlatforms = []}: Props) {
235
235
< div className = { styles [ 'input-wrapper' ] } >
236
236
< input
237
237
type = "text"
238
- placeholder = "Search or ask a question "
238
+ placeholder = "Search Docs "
239
239
aria-label = "Search"
240
240
className = { styles [ 'search-input' ] }
241
241
value = { query }
@@ -250,38 +250,40 @@ export function Search({path, autoFocus, searchPlatforms = []}: Props) {
250
250
{ inputFocus ? 'esc' : '⌘K' }
251
251
</ kbd >
252
252
</ div >
253
+ { showChatBot && (
254
+ < Fragment >
255
+ < span className = "text-[var(--desatPurple10)] hidden md:inline" > or</ span >
256
+ < Button
257
+ asChild
258
+ variant = "ghost"
259
+ color = "gray"
260
+ size = "3"
261
+ radius = "medium"
262
+ className = "font-medium text-[var(--foreground)] py-2 px-3 uppercase cursor-pointer kapa-ai-class hidden md:flex"
263
+ >
264
+ < div >
265
+ < svg
266
+ xmlns = "http://www.w3.org/2000/svg"
267
+ fill = "none"
268
+ viewBox = "0 0 24 24"
269
+ strokeWidth = { 1.5 }
270
+ stroke = "currentColor"
271
+ className = "size-5"
272
+ >
273
+ < path
274
+ strokeLinecap = "round"
275
+ strokeLinejoin = "round"
276
+ d = "M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09ZM18.259 8.715 18 9.75l-.259-1.035a3.375 3.375 0 0 0-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 0 0 2.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 0 0 2.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 0 0-2.456 2.456ZM16.894 20.567 16.5 21.75l-.394-1.183a2.25 2.25 0 0 0-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 0 0 1.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 0 0 1.423 1.423l1.183.394-1.183.394a2.25 2.25 0 0 0-1.423 1.423Z"
277
+ />
278
+ </ svg >
279
+ < span > Ask AI</ span >
280
+ </ div >
281
+ </ Button >
282
+ </ Fragment >
283
+ ) }
253
284
</ div >
254
285
{ query . length >= 2 && inputFocus && (
255
286
< div className = { styles [ 'sgs-search-results' ] } >
256
- < div className = { styles [ 'sgs-ai' ] } >
257
- < button
258
- id = "ai-list-entry"
259
- className = { `${ styles [ 'sgs-ai-button' ] } ${
260
- focused ?. id === 'ai-list-entry' ? styles [ 'sgs-ai-focused' ] : ''
261
- } `}
262
- onClick = { ( ) => {
263
- if ( window . Kapa ?. open ) {
264
- // close search results
265
- setInputFocus ( false ) ;
266
- // open kapa modal
267
- window . Kapa . open ( { query : `Explain ${ query } ` , submit : true } ) ;
268
- }
269
- } }
270
- >
271
- < MagicIcon className = "size-6 text-[var(--sgs-color-hit-highlight)] flex-shrink-0" />
272
- < div className = { styles [ 'sgs-ai-button-content' ] } >
273
- < h6 >
274
- Ask Sentry about{ ' ' }
275
- < span > { query . length > 30 ? query . slice ( 0 , 30 ) + '...' : query } </ span >
276
- </ h6 >
277
- < div className = { styles [ 'sgs-ai-hint' ] } >
278
- Get an AI-powered answer to your question
279
- </ div >
280
- </ div >
281
- < ArrowRightIcon className = "size-5 text-[var(--sgs-color-hit-highlight)] ml-auto flex-shrink-0" />
282
- </ button >
283
- </ div >
284
-
285
287
{ loading && < Logo loading /> }
286
288
287
289
{ ! loading && totalHits > 0 && (
@@ -294,6 +296,14 @@ export function Search({path, autoFocus, searchPlatforms = []}: Props) {
294
296
/>
295
297
) }
296
298
299
+ { ! loading && totalHits === 0 && (
300
+ < div className = { styles [ 'sgs-hit-empty-state' ] } >
301
+ < button className = "kapa-ai-class font-bold" >
302
+ Can't find what you're looking for? Ask our AI!
303
+ </ button >
304
+ </ div >
305
+ ) }
306
+
297
307
{ ! loading && ! showOffsiteResults && (
298
308
< div className = { styles [ 'sgs-expand-results' ] } >
299
309
< button
0 commit comments