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
20 changes: 5 additions & 15 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import PopularContacts from './components/PopularContacts.js';
import contacts from './data/contacts.json';
import './App.css';


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>
<h1>Popular Contacts</h1>
<PopularContacts contactsArray={contacts}></PopularContacts>
</div>
);
}
Expand Down
37 changes: 37 additions & 0 deletions src/components/Card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
*{
margin: 0;
padding: 0;
}

.card{
width: 360px;
height: 200px;
border: 1x solid black;
display: flex;
flex-direction: row;
justify-items: flex-start;
align-content: center;
/* margin: 20px; */
margin: 0 auto;

}

.score{
display: flex;
flex-direction: column;
justify-items: flex-start;
margin-left: 20px;
}

.card h1{
font-size: 1.2em;
}
.card h3{
font-size: .8em;
text-align: left;
}

.card img{
width: 140px;
}

18 changes: 18 additions & 0 deletions src/components/Card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import './Card.css';

const Card = (props) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good use of a functional component here :)

return (
<li>
<div className="card">
<img src={props.pic} alt="" />
<div className="score">
<h1>{props.name}</h1>
<h3>{props.popular}</h3>
</div>
</div>
</li>
)
}

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



class PopularContacts extends Component {
constructor(props){
super();
this.state = {
contacts : props.contactsArray.slice(0,5)
}
}



render() {
return (
<ul>
{/* <li>
Picture Name Popularity
</li> */}
{
this.state.contacts.map ((oneContact,index) => {
return (
<Card key={index}
name={oneContact.name}
pic={oneContact.pictureUrl}
popular={oneContact.popularity}
/>
)
})

}
</ul>
)
}
}
export default PopularContacts;