webapp/src/components/_shared/SearchField.tsx

30 lines
766 B
TypeScript
Raw Normal View History

2022-11-18 18:33:31 +00:00
import styles from './SearchField.module.scss'
import { Icon } from './Icon'
import { t } from '../../utils/intl'
2022-12-17 03:27:00 +00:00
import { clsx } from 'clsx'
2022-11-18 18:33:31 +00:00
type SearchFieldProps = {
onChange: (value: string) => void
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())
2022-11-18 18:33:31 +00:00
return (
<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')}
/>
<label for="search-field">Поиск</label>
2022-11-18 18:33:31 +00:00
</div>
)
}