Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import contacts from './data/contacts.json';
import ListContacts from './ListContacts';


class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<ListContacts/>
</div>
);
}
Expand Down
19 changes: 19 additions & 0 deletions src/Card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';

const Card = ({ picture, name, popularity }) => {
return (
<tr>
<td>
<img width="80" src={picture} alt=""/>
</td>
<td>
<h2>{name}</h2>
</td>
<td>
<p>{popularity}</p>
</td>
</tr>
)
}

export default Card;
80 changes: 80 additions & 0 deletions src/ListContacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React, { Component } from 'react';
import Card from './Card';
import contacts from './data/contacts.json';


class ListContacts extends Component {
constructor(){
super();
this.state = {
contacts: [
{
"name": "Idris Elba",
"pictureUrl": "https://image.tmdb.org/t/p/w500/d9NkfCwczP0TjgrjpF94jF67SK8.jpg",
"popularity": 11.622713
},
{
"name": "Jessica Chastain",
"pictureUrl": "https://image.tmdb.org/t/p/w500/nkFrkn5NZVGWb4b2X0yIcXezhyt.jpg",
"popularity": 8.324357
},
{
"name": "Johnny Depp",
"pictureUrl": "https://image.tmdb.org/t/p/w500/kbWValANhZI8rbWZXximXuMN4UN.jpg",
"popularity": 15.656534
},
{
"name": "Emilia Clarke",
"pictureUrl": "https://image.tmdb.org/t/p/w500/j7d083zIMhwnKro3tQqDz2Fq1UD.jpg",
"popularity": 16.211837
},
{
"name": "Leonardo DiCaprio",
"pictureUrl": "https://image.tmdb.org/t/p/w500/A85WIRIKVsD2DeUSc8wQ4fOKc4e.jpg",
"popularity": 11.245333
}]

}
}

randomContact = () => {
return Math.floor(Math.random() * this.state.contacts.length);
}


/* const contactsCopy = [...this.state.contacts]
contactsCopy.splice(contactIndex, 1);
this.ListeningStateChangedEvent({
contacts: contactsCopy
}) */


render() {
return (
<div>
<h1>IronContacts</h1>
<button>Add Random</button>
<table style={tableStyle}>
<tr>
<th>Picture</th>
<th>Name</th>
<th>popularity</th>
</tr>
{
this.state.contacts.map((oneContact, index) =>
<Card key={index} picture={oneContact.pictureUrl} name={oneContact.name} popularity={oneContact.popularity} />)
}

</table>
</div>
)
}
}



export default ListContacts;

const tableStyle = {
margin: "0 auto"
}