2022-11-18 18:33:31 +00:00
|
|
|
|
import styles from './SearchField.module.scss'
|
|
|
|
|
import { Icon } from './Icon'
|
2023-02-17 09:21:02 +00:00
|
|
|
|
|
2022-12-17 03:27:00 +00:00
|
|
|
|
import { clsx } from 'clsx'
|
2023-02-17 09:21:02 +00:00
|
|
|
|
import { useLocalize } from '../../context/localize'
|
2022-11-18 18:33:31 +00:00
|
|
|
|
|
|
|
|
|
type SearchFieldProps = {
|
|
|
|
|
onChange: (value: string) => void
|
2022-11-28 22:14:19 +00:00
|
|
|
|
class?: string
|
2022-11-18 18:33:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const SearchField = (props: SearchFieldProps) => {
|
2022-11-20 21:25:59 +00:00
|
|
|
|
const handleInputChange = (event) => props.onChange(event.target.value.trim())
|
2023-02-17 09:21:02 +00:00
|
|
|
|
const { t } = useLocalize()
|
2022-11-18 18:33:31 +00:00
|
|
|
|
return (
|
2022-11-28 22:14:19 +00:00
|
|
|
|
<div class={clsx(styles.searchField, props.class)}>
|
2022-11-18 18:33:31 +00:00
|
|
|
|
<label for="search-field">
|
|
|
|
|
<Icon name="search" class={styles.icon} />
|
|
|
|
|
</label>
|
|
|
|
|
<input
|
|
|
|
|
id="search-field"
|
|
|
|
|
type="text"
|
|
|
|
|
class="search-input"
|
|
|
|
|
onInput={handleInputChange}
|
|
|
|
|
placeholder={t('Search')}
|
|
|
|
|
/>
|
2022-11-28 22:14:19 +00:00
|
|
|
|
<label for="search-field">Поиск</label>
|
2022-11-18 18:33:31 +00:00
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|