forked from shahibuzzaman/covid19-tracker-reactJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountries.js
More file actions
76 lines (68 loc) · 1.77 KB
/
Copy pathCountries.js
File metadata and controls
76 lines (68 loc) · 1.77 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import React, { Component } from 'react';
import Country from './responsive/Country';
import {
InputGroup,
InputGroupText,
InputGroupAddon,
Input,
Navbar
} from 'reactstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faSearch } from '@fortawesome/free-solid-svg-icons';
class Countries extends Component {
state = {
search: '',
filter: null
};
onChange = e => {
this.setState({ search: e.target.value });
};
render() {
const { countries } = this.props;
const filteredCountries = countries.filter(countries => {
return (
countries.country
.toLowerCase()
.indexOf(this.state.search.toLowerCase()) !== -1
);
});
return (
<div style={{ marginTop: '70px' }}>
<Navbar
light
expand='md'
className='fixed-top'
style={{ width: '35%', marginLeft: '32%', marginTop: '5px' }}
>
<InputGroup size='sm'>
<InputGroupAddon addonType='prepend'>
<InputGroupText>
<FontAwesomeIcon icon={faSearch} />
</InputGroupText>
</InputGroupAddon>
<Input
placeholder='sm'
bsSize='sm'
type='text'
name='text'
id='text'
placeholder='Search by Country Name ....'
onChange={this.onChange}
/>
</InputGroup>
</Navbar>
<div style={userStyle}>
{filteredCountries.map(countries => (
<Country key={countries.id} countries={countries} />
))}
</div>
</div>
);
}
}
const userStyle = {
display: 'grid',
gridTemplateColumns: 'repeat(3, 1fr)',
gridGap: '1rem'
};
export default Countries;