2022-06-08 11:48:22 +08:00
|
|
|
import { css, cx } from '@emotion/css'
|
|
|
|
import Icon from '../../Icon'
|
2022-06-11 00:19:07 +08:00
|
|
|
import { breakpoint as bp } from '@/web/utils/const'
|
2022-06-25 13:47:07 +08:00
|
|
|
import { useNavigate } from 'react-router-dom'
|
|
|
|
import { useState } from 'react'
|
2022-06-08 11:48:22 +08:00
|
|
|
|
|
|
|
const SearchBox = () => {
|
2022-06-25 13:47:07 +08:00
|
|
|
const navigate = useNavigate()
|
|
|
|
const [searchText, setSearchText] = useState('')
|
|
|
|
|
2022-06-08 11:48:22 +08:00
|
|
|
return (
|
2022-06-11 00:19:07 +08:00
|
|
|
<div
|
|
|
|
className={cx(
|
2022-07-12 22:42:50 +08:00
|
|
|
'app-region-no-drag flex items-center rounded-full bg-white/10 p-2.5 text-white/40 backdrop-blur-3xl',
|
2022-06-11 00:19:07 +08:00
|
|
|
css`
|
|
|
|
${bp.lg} {
|
|
|
|
min-width: 284px;
|
|
|
|
}
|
|
|
|
`
|
|
|
|
)}
|
|
|
|
>
|
2022-06-08 11:48:22 +08:00
|
|
|
<Icon name='search' className='mr-2.5 h-7 w-7' />
|
|
|
|
<input
|
2022-06-11 00:19:07 +08:00
|
|
|
placeholder='Search'
|
|
|
|
className={cx(
|
2022-07-12 22:42:50 +08:00
|
|
|
'flex-shrink bg-transparent font-medium placeholder:text-white/40 dark:text-white/80',
|
2022-06-11 00:19:07 +08:00
|
|
|
css`
|
2022-06-14 23:23:34 +08:00
|
|
|
@media (max-width: 420px) {
|
2022-06-11 00:19:07 +08:00
|
|
|
width: 142px;
|
|
|
|
}
|
|
|
|
`
|
|
|
|
)}
|
2022-06-25 13:47:07 +08:00
|
|
|
value={searchText}
|
|
|
|
onChange={e => setSearchText(e.target.value)}
|
|
|
|
onKeyDown={e => {
|
|
|
|
if (e.key !== 'Enter') return
|
|
|
|
e.preventDefault()
|
|
|
|
navigate(`/search/${searchText}`)
|
|
|
|
}}
|
2022-06-08 11:48:22 +08:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SearchBox
|