let CONTACTS = [
{
id:1,
name: 'Kamila Abcentova',
phoneNumber: '+79503124111',
image: 'https://i.pinimg.com/736x/63/57/fa/6357fa6703775b165e739a1c6a1d0899--berges-portrait-paintings.jpg'
},
{
id:2,
name: 'Denis Abramov',
phoneNumber: '+79506224211',
image: 'https://pbs.twimg.com/media/BvVsFVBCcAAT_Pt.jpg:large'
},
{
id:3,
name: 'Kristian Sendler',
phoneNumber: '+79236444211',
image: 'https://thairomances.com/userfiles/ProfilePhoto/14244/39093-full_size.jpg?v=3'
},
{
id:4,
name: 'Marat Kizombov',
phoneNumber: '+79321445511',
image: 'http://funstories.lol/wp-content/uploads/2016/07/2-121-768x768.jpg'
}
];
class Contact extends React.Component{
render(){
return <li className='contact'>
<img className='contact-image' src={this.props.image} width='60px' height='60px'/>
<div className='contact-info'>
<div className='contact-name'>{this.props.name}</div>
<div className='contact-phone'>{this.props.phoneNumber}</div>
</div>
</li>
}
}
class ContactList extends React.Component{
constructor(props){
super(props);
this.handleSearch = this.handleSearch.bind(this);
}
handleSearch(event){
console.log(event)
}
render(){
return(
<div className='contacts'>
<input type='text' className='search-fields' onChange={this.handleSearch}/>
<ul className='contacts-list'>
{
CONTACTS.map(function(el){
return <Contact
key={el.id}
name={el.name}
phoneNumber={el.phoneNumber}
image={el.image}
/>;
})
}
</ul>
</div>
);
}
}
ReactDOM.render(
<ContactList/>,
document.getElementById('root')
)
let CONTACTS = [
{
id:1,
name: 'Kamila Abcentova',
phoneNumber: '+79503124111',
image: 'https://i.pinimg.com/736x/63/57/fa/6357fa6703775b165e739a1c6a1d0899--berges-portrait-paintings.jpg'
},
{
id:2,
name: 'Denis Abramov',
phoneNumber: '+79506224211',
image: 'https://pbs.twimg.com/media/BvVsFVBCcAAT_Pt.jpg:large'
},
{
id:3,
name: 'Kristian Sendler',
phoneNumber: '+79236444211',
image: 'https://thairomances.com/userfiles/ProfilePhoto/14244/39093-full_size.jpg?v=3'
},
{
id:4,
name: 'Marat Kizombov',
phoneNumber: '+79321445511',
image: 'http://funstories.lol/wp-content/uploads/2016/07/2-121-768x768.jpg'
}
];
class Contact extends React.Component{
render(){
return <li className='contact'>
<img className='contact-image' src={this.props.image} width='60px' height='60px'/>
<div className='contact-info'>
<div className='contact-name'>{this.props.name}</div>
<div className='contact-phone'>{this.props.phoneNumber}</div>
</div>
</li>
}
}
class ContactList extends React.Component{
constructor(props){
super(props);
this.state={
input=""
}
this.handleSearch = this.handleSearch.bind(this);
}
handleSearch(el){
console.log(el.target.value)
this.setState({
input:el.target.value
})
}
render(){
return(
<div className='contacts'>
<input type='text' className='search-fields' onChange={this.handleSearch} value={this.state.input}/>
<div>{this.state.input}</div>
<ul className='contacts-list'>
{
CONTACTS.map(function(el){
return <Contact
key={el.id}
name={el.name}
phoneNumber={el.phoneNumber}
image={el.image}
/>;
})
}
</ul>
</div>
);
}
}
ReactDOM.render(
<ContactList/>,
document.getElementById('root')
)