-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathSearchBar.tsx
More file actions
54 lines (49 loc) · 1.22 KB
/
SearchBar.tsx
File metadata and controls
54 lines (49 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { observer } from 'mobx-react';
import { FC, useContext } from 'react';
import {
Button,
Form,
FormControlProps,
FormProps,
InputGroup,
InputGroupProps,
} from 'react-bootstrap';
import { I18nContext } from '../../models/Translation';
import styles from './SearchBar.module.less';
export interface SearchBarProps
extends
Omit<FormProps, 'onChange'>,
Pick<InputGroupProps, 'size'>,
Pick<FormControlProps, 'name' | 'placeholder' | 'defaultValue' | 'value' | 'onChange'> {
expanded?: boolean;
}
export const SearchBar: FC<SearchBarProps> = observer(
({
action = '/search/activity',
size,
name = 'keywords',
placeholder,
expanded = true,
defaultValue,
value,
onChange,
...props
}) => {
const { t } = useContext(I18nContext);
placeholder ??= t('keywords');
return (
<Form {...{ action, ...props }}>
<InputGroup size={size}>
<Form.Control
className={expanded ? '' : styles.input}
type="search"
{...{ name, placeholder, defaultValue, value, onChange }}
/>
<Button type="submit" variant="light">
🔍
</Button>
</InputGroup>
</Form>
);
},
);