diff --git a/src/App.css b/src/App.css index b41d297ca..1eaad2196 100755 --- a/src/App.css +++ b/src/App.css @@ -1,13 +1,39 @@ .App { text-align: center; } - +.row { + display: flex; + flex-wrap: wrap; + justify-content: center; + flex-direction: column; +} .App-logo { animation: App-logo-spin infinite 20s linear; height: 40vmin; pointer-events: none; } - +.h2 { + display: flex; + flex-direction: row; + justify-content: space-around; +} +li { + display: flex; + flex-direction: row; + } +ul { + display: flex; + justify-content: center; + flex-direction: column; +} +.img { + width: 2rem; + height: 3rem; + margin: 0 6rem; +} +p { + margin: 0 3rem; +} .App-header { background-color: #282c34; min-height: 100vh; diff --git a/src/App.js b/src/App.js index 7e261ca47..31c4cfb15 100755 --- a/src/App.js +++ b/src/App.js @@ -1,28 +1,80 @@ import React, { Component } from 'react'; -import logo from './logo.svg'; import './App.css'; +import contacts from './data/contacts.json'; +import List from './Components/List'; +import Add from './Components/Add'; +import ByName from './Components/ByName'; +import ByPop from './Components/ByPop'; + class App extends Component { + state = { + contacts: contacts.slice(0,5) + }; + + getRandomInt = (min, max) => { + return Math.floor(Math.random() * (max - min)) + min; + }; + + random = () => { + console.log("Click") + const contactRandom = this.getRandomInt(0,contacts.length); + + this.setState({ + contacts: [...this.state.contacts, contacts[contactRandom]], + + }); + }; + SortName = () => { + this.setState({ + contacts: this.state.contacts.sort((a,b) => (a.name > b.name) ? 1 : ((b.name > a.name) ? -1 : 0)), + }) + }; + + SortPop = () => { + this.setState({ + contacts: this.state.contacts.sort((a,b) => (a.popularity < b.popularity) ? 1 : ((b.popularity < a.popularity) ? -1 : 0)), + }) + }; + + deleteContact = (index) => { + this.state.contacts.splice(index, 1); + this.setState({ + contacts: [...this.state.contacts], + }) + } + + + render() { + const {contacts} = this.state; return ( + <>
- Edit src/App.js and save to reload.
-
{this.props.list.name}
+{this.props.list.popularity}
+ +