@@ -12,14 +12,14 @@ export const SearchInput = ({
1212 searchRef,
1313 onSearch,
1414 className,
15- placeholderFocused = 'Search' ,
16- placeholderUnfocused = 'Press / to search'
15+ placeholderFocusedOrMobile = 'Search' ,
16+ placeholderUnfocusedOnlyDesktop = 'Press / to search'
1717} : {
1818 searchRef : RefObject < HTMLInputElement >
1919 onSearch : ( value : string ) => void
2020 className ?: string
21- placeholderFocused ?: string
22- placeholderUnfocused ?: string
21+ placeholderFocusedOrMobile ?: string
22+ placeholderUnfocusedOnlyDesktop ?: string
2323} ) => {
2424 const [ isFocused , setIsFocused ] = useState ( false )
2525
@@ -59,18 +59,23 @@ export const SearchInput = ({
5959 shouldIgnoreWhen = { [ isModifierPressed , ( ) => isFocused ] }
6060 targetRef = "document"
6161 />
62- < input
63- onBlur = { ( ) => setIsFocused ( false ) }
64- onFocus = { ( ) => setIsFocused ( true ) }
65- ref = { searchRef }
66- type = "text"
67- placeholder = { isFocused ? placeholderFocused : placeholderUnfocused }
68- className = { classNames (
69- 'text-sm dark:text-gray-100 block border-gray-300 dark:border-gray-750 rounded-md dark:bg-gray-750 max-w-64 w-full dark:placeholder:text-gray-400 focus:outline-none focus:ring-3 focus:ring-indigo-500/20 dark:focus:ring-indigo-500/25 focus:border-indigo-500' ,
70- className
71- ) }
72- onChange = { debouncedOnSearchInputChange }
73- />
62+ < div className = { classNames ( 'relative max-w-64 w-full' , className ) } >
63+ < input
64+ onBlur = { ( ) => setIsFocused ( false ) }
65+ onFocus = { ( ) => setIsFocused ( true ) }
66+ ref = { searchRef }
67+ type = "text"
68+ placeholder = " "
69+ className = "peer w-full text-sm dark:text-gray-100 block border-gray-300 dark:border-gray-750 rounded-md dark:bg-gray-750 dark:placeholder:text-gray-400 focus:outline-none focus:ring-3 focus:ring-indigo-500/20 dark:focus:ring-indigo-500/25 focus:border-indigo-500"
70+ onChange = { debouncedOnSearchInputChange }
71+ />
72+ < span className = "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-sm text-gray-400 dark:text-gray-400 peer-[:not(:placeholder-shown)]:hidden md:peer-[:not(:focus)]:hidden" >
73+ { placeholderFocusedOrMobile }
74+ </ span >
75+ < span className = "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-sm text-gray-400 dark:text-gray-400 peer-[:not(:placeholder-shown)]:hidden hidden md:peer-[:not(:focus)]:block peer-focus:hidden" >
76+ { placeholderUnfocusedOnlyDesktop }
77+ </ span >
78+ </ div >
7479 </ >
7580 )
7681}
0 commit comments