diff --git a/src/App.css b/src/App.css
index b41d297ca..30113697a 100755
--- a/src/App.css
+++ b/src/App.css
@@ -31,3 +31,31 @@
transform: rotate(360deg);
}
}
+
+img {
+ width: 100px;
+ height: 150px;
+}
+
+.container {
+ display: flex;
+ flex-direction: column;
+}
+
+h1 {
+ text-align: center;
+}
+.titles {
+ display: flex;
+ justify-content: space-around;
+ margin-left:15%;
+ margin-right: 15%;
+}
+
+ul {
+ margin-left:15%;
+ margin-right: 15%;
+ padding: 0;
+ display: flex;
+ justify-content: space-around;
+}
\ No newline at end of file
diff --git a/src/App.js b/src/App.js
index 7e261ca47..f5d2c1abb 100755
--- a/src/App.js
+++ b/src/App.js
@@ -1,26 +1,76 @@
import React, { Component } from 'react';
-import logo from './logo.svg';
import './App.css';
+import contacts from './data/contacts.json'
+import Contact from './components/Contact'
+import Header from './components/Header'
+
+
class App extends Component {
+
+ state = {
+ contactsArray: contacts.slice(0, 5)
+ }
+
+ addRandom = () => {
+ const randomContact = contacts[Math.floor(Math.random() * contacts.length)];
+ this.setState({
+ contactsArray: [...this.state.contactsArray, randomContact]
+ })
+ }
+
+ sortByName = () => {
+ this.setState({
+ contactsArray: this.state.contactsArray.sort(function (a, b) {
+ if (a.name < b.name) { return -1; }
+ if (a.name > b.name) { return 1; }
+ return 0;
+ })
+ })
+ }
+
+ sortByPopularity = () => {
+ this.setState({
+ contactsArray: this.state.contactsArray.sort(function (a, b) {
+ return b.popularity - a.popularity;
+ })
+ })
+ }
+
+ deleteContact = (contact) => {
+ let { contactsArray } = this.state
+ contactsArray.splice(contact, 1)
+ this.setState({
+ contactsArray
+ })
+ }
+
+ renderList() {
+ return this.state.contactsArray.map((contact, index) => {
+ return
- Edit src/App.js and save to reload.
-
{name}
+{popularity}
+ +