@@ -4,6 +4,7 @@ import { useEffect, useRef, useState } from 'react';
44
55import { tString , useLanguage } from '@/intl/client' ;
66import { tcls } from '@/lib/tailwind' ;
7+ import { CustomizationAIMode } from '@gitbook/api' ;
78import { Icon } from '@gitbook/icons' ;
89import { Button , variantClasses } from '../primitives' ;
910import { useClassnames } from '../primitives/StyleProvider' ;
@@ -13,7 +14,7 @@ interface SearchInputProps {
1314 onKeyDown : ( event : React . KeyboardEvent < HTMLInputElement > ) => void ;
1415 onFocus : ( ) => void ;
1516 value : string ;
16- withAI ?: boolean ;
17+ aiMode : CustomizationAIMode ;
1718 isOpen : boolean ;
1819 className ?: string ;
1920}
@@ -26,7 +27,7 @@ const sizeClasses = ['text-sm', 'px-3.5', 'py-1.5', 'md:circular-corners:px-4'];
2627 */
2728export const SearchInput = React . forwardRef < HTMLDivElement , SearchInputProps > (
2829 function SearchInput ( props , ref ) {
29- const { onChange, onKeyDown, onFocus, value, withAI = false , isOpen, className } = props ;
30+ const { onChange, onKeyDown, onFocus, value, aiMode , isOpen, className } = props ;
3031 const inputRef = useRef < HTMLInputElement > ( null ) ;
3132
3233 const language = useLanguage ( ) ;
@@ -59,7 +60,7 @@ export const SearchInput = React.forwardRef<HTMLDivElement, SearchInputProps>(
5960 sizeClasses ,
6061 // Additional custom styles
6162 'has-[input:focus]:-translate-y-px h-9 grow cursor-pointer px-2.5 has-[input:focus]:bg-tint-base depth-subtle:has-[input:focus]:shadow-lg depth-subtle:has-[input:focus]:shadow-primary-subtle has-[input:focus-visible]:ring-2 has-[input:focus-visible]:ring-primary-hover md:cursor-text' ,
62- 'theme-bold:has-[input:focus-visible]:border-header-link/6 theme-bold:has-[input:focus-visible]:bg-header-link/3' ,
63+ 'theme-bold:border-header-link/3 theme-bold: has-[input:focus-visible]:border-header-link/5 theme-bold:has-[input:focus-visible]:bg-header-link/3 theme-bold:has-[input:focus-visible]:ring-header-link/5 ' ,
6364 'theme-bold:before:absolute theme-bold:before:inset-0 theme-bold:before:bg-header-background/7 theme-bold:before:backdrop-blur-xl ' , // Special overlay to make the transparent colors of theme-bold visible.
6465 'relative z-30 shrink grow justify-start max-md:absolute max-md:right-0' ,
6566 isOpen ? 'max-md:w-56' : 'max-md:w-[38px]' ,
@@ -73,7 +74,7 @@ export const SearchInput = React.forwardRef<HTMLDivElement, SearchInputProps>(
7374 size = "medium"
7475 iconOnly
7576 icon = "circle-xmark"
76- className = "-ml-1.5 -mr-1 animate-scaleIn px-1.5 theme-bold:text-header-link theme-bold:hover:bg-header-link/3 "
77+ className = "-ml-1.5 -mr-1 animate-scaleIn px-1.5"
7778 onClick = { ( ) => {
7879 onChange ( '' ) ;
7980 inputRef . current ?. focus ( ) ;
@@ -89,15 +90,17 @@ export const SearchInput = React.forwardRef<HTMLDivElement, SearchInputProps>(
8990 onKeyDown = { onKeyDown }
9091 onChange = { ( event ) => onChange ( event . target . value ) }
9192 value = { value }
92- placeholder = { `${ tString ( language , withAI ? 'search_or_ask' : 'search' ) } ...` }
93+ // We only show "search or ask" if the search input actually handles both search and ask.
94+ placeholder = { `${ tString ( language , aiMode === CustomizationAIMode . Search ? 'search_or_ask' : 'search' ) } ...` }
9395 maxLength = { 512 }
96+ size = { 10 }
9497 className = { tcls (
9598 'peer z-10 min-w-0 grow bg-transparent py-0.5 text-tint-strong theme-bold:text-header-link outline-none transition-[width] duration-300 contain-paint placeholder:text-tint theme-bold:placeholder:text-current theme-bold:placeholder:opacity-7' ,
9699 isOpen ? '' : 'max-md:opacity-0'
97100 ) }
98101 ref = { inputRef }
99102 />
100- < Shortcut />
103+ { ! isOpen ? < Shortcut /> : null }
101104 </ div >
102105 </ div >
103106 ) ;
@@ -124,7 +127,7 @@ function Shortcut() {
124127 < div
125128 aria-busy = { operatingSystem === null ? 'true' : undefined }
126129 className = { tcls (
127- `shortcut -mr-1 hidden justify-end gap-0.5 whitespace-nowrap text-xs [font-feature-settings:"calt",_"case"] contrast-more:text-tint-strong md:flex` ,
130+ `shortcut -mr-1 relative z-10 hidden justify-end gap-0.5 whitespace-nowrap text-xs [font-feature-settings:"calt",_"case"] after:absolute after:right-full after:z-20 after:h-full after:w-8 after:bg-gradient-to-r after:from-transparent after:to-tint-base theme-bold:after:to-transparent after:content-['' ] contrast-more:text-tint-strong md:flex` ,
128131 operatingSystem
129132 ? 'motion-safe:animate-fadeIn motion-reduce:opacity-11'
130133 : 'opacity-0'
0 commit comments