diff --git a/src/App.css b/src/App.css index 74b5e05..58b874e 100644 --- a/src/App.css +++ b/src/App.css @@ -1,38 +1,53 @@ .App { text-align: center; + display: flex; + flex-direction: column; + align-items: center; + font-family: "Courier New", Courier, monospace; + font-weight: 700; } -.App-logo { - height: 40vmin; - pointer-events: none; +.single-contact img { + width: 80px; + height: auto; + border: 2px solid #ffd700; + margin: 2px; } -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } +table { + border-collapse: collapse; + border: 2px solid #ffd700; + margin: 20px; +} +table th { + background-color: #ffd700; + color: #ffffff; + padding: 10px 20px; + font-size: 24px; } -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; +h1 { + color: #ffd700; } -.App-link { - color: #61dafb; +.buttons button { + color: #ffffff; + background-color: #ffd700; + padding: 10px; + margin: 10px; + border-radius: 15px; + border: none; + font-family: "Courier New", Courier, monospace; + font-weight: 900; + font-size: 20px; + cursor: pointer; } -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } +.del-button { + padding: 10px; + border-radius: 15px; + border: none; + font-family: "Courier New", Courier, monospace; + font-weight: 900; + cursor: pointer; } diff --git a/src/App.js b/src/App.js index 3784575..c2d0b11 100644 --- a/src/App.js +++ b/src/App.js @@ -1,23 +1,79 @@ -import logo from './logo.svg'; import './App.css'; +import contactsData from "./contacts.json"; +import { useState } from "react"; function App() { + const [contacts, setContacts] = useState(contactsData.slice(0, 5)); + + let contactList = contacts.map((contact) => ( + + + {contact.name} + + {contact.name} + {contact.popularity.toFixed(2)} + {contact.wonOscar ? "🏆" : "-"} + {contact.wonEmmy ? "🏆" : "-"} + + + + + )); + + let addRandomContact = () => { + let contactsID = contacts.map((contact) => contact.id); + let otherContacts = contactsData.filter( + (contact) => !contactsID.includes(contact.id) + ); + let randomIndex = Math.floor(Math.random() * otherContacts.length); + setContacts([...contacts, otherContacts[randomIndex]]); + }; + + let sortByPopularity = () => { + let contactList = [...contacts]; + contactList.sort((a, b) => b.popularity - a.popularity); + setContacts(contactList); + }; + + let sortByName = () => { + let contactList = [...contacts]; + contactList.sort((a, b) => { + if (b.name > a.name) return -1; + if (b.name < a.name) return 1; + return 0; + }); + setContacts(contactList); + }; + + function contactDelete(e) { + let cID = e.target.parentNode.id; + let contactList = contacts.filter((contact) => contact.id !== cID); + setContacts(contactList); + } return (
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
+

🌟CONTACTS🌟

+
+ + + +
+ + + + + + + + + + + + {contactList} +
PictureNamePopularityWon-OscarWon-EmmyActions
+
); }