2023-06-15 11:00:46 +00:00
|
|
|
import classNames from 'classnames'
|
2023-07-03 07:39:34 +00:00
|
|
|
import { ChangeEvent, forwardRef } from 'react'
|
2023-06-15 11:00:46 +00:00
|
|
|
|
|
|
|
import { Search } from 'components/Icons'
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
value: string
|
|
|
|
placeholder: string
|
2023-07-03 07:39:34 +00:00
|
|
|
autofocus?: boolean
|
2023-06-15 11:00:46 +00:00
|
|
|
onChange: (value: string) => void
|
|
|
|
}
|
|
|
|
|
2023-07-03 07:39:34 +00:00
|
|
|
const SearchBar = (props: Props) => {
|
2023-06-15 11:00:46 +00:00
|
|
|
function onChange(event: ChangeEvent<HTMLInputElement>) {
|
|
|
|
props.onChange(event.target.value)
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
'flex w-full items-center justify-between rounded-sm bg-white/10 p-2.5',
|
|
|
|
'relative isolate max-w-full overflow-hidden rounded-base',
|
|
|
|
'before:content-[" "] before:absolute before:inset-0 before:-z-1 before:rounded-base before:p-[1px] before:border-glas',
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<Search width={14} height={14} className='mr-2.5 text-white' />
|
|
|
|
<input
|
|
|
|
value={props.value}
|
|
|
|
className='h-full w-full bg-transparent text-xs placeholder-white/30 outline-none'
|
|
|
|
placeholder={props.placeholder}
|
|
|
|
onChange={(event) => onChange(event)}
|
2023-07-03 07:39:34 +00:00
|
|
|
autoFocus={props.autofocus}
|
2023-06-15 11:00:46 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2023-07-03 07:39:34 +00:00
|
|
|
|
|
|
|
export default forwardRef(SearchBar)
|