1
0
Fork 0
blog/src/components/molecules/Search/SearchInput.tsx

35 lines
744 B
TypeScript
Raw Normal View History

2020-05-22 14:38:19 +02:00
import React, { ReactElement } from 'react'
2019-10-28 23:00:55 +01:00
import Input from '../../atoms/Input'
2019-11-15 22:10:53 +01:00
import Icon from '../../atoms/Icon'
2021-03-14 01:34:04 +01:00
import { searchInput, searchInputClose } from './SearchInput.module.css'
2019-10-02 13:35:50 +02:00
export default function SearchInput({
value,
onToggle,
onChange
}: {
value: string
onToggle(): void
2019-10-02 20:48:59 +02:00
onChange(e: Event): void
2020-05-22 14:38:19 +02:00
}): ReactElement {
2019-10-02 13:35:50 +02:00
return (
<>
<Input
2021-03-14 01:34:04 +01:00
className={searchInput}
2019-10-02 13:35:50 +02:00
type="search"
placeholder="Search everything"
autoFocus // eslint-disable-line
value={value}
onChange={onChange}
/>
<button
2021-03-14 01:34:04 +01:00
className={searchInputClose}
2019-10-02 13:35:50 +02:00
onClick={onToggle}
title="Close search"
>
2019-11-15 22:10:53 +01:00
<Icon name="X" />
2019-10-02 13:35:50 +02:00
</button>
</>
)
}