diff --git a/src/App.css b/src/App.css index 74b5e05..36ff3de 100644 --- a/src/App.css +++ b/src/App.css @@ -1,38 +1,60 @@ -.App { +body { + font-family: Arial, sans-serif; + background-color: #f0f0f0; + margin: 0; + padding: 0; +} + +.container { + max-width: 800px; + margin: 20px auto; + padding: 20px; + background-color: #fff; + border-radius: 8px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +h1 { text-align: center; + margin-bottom: 20px; +} + +button { + margin: 10px 10px 10px 10px; + padding: 8px 16px; + font-size: 16px; + background-color: #007bff; + color: #fff; + border: none; + border-radius: 4px; + cursor: pointer; +} + +button:hover { + background-color: #0056b3; } -.App-logo { - height: 40vmin; - pointer-events: none; +table { + width: 100%; + border-collapse: collapse; } -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } +table th, +table td { + padding: 10px; + border-bottom: 1px solid #ddd; + text-align: left; } -.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; +table th { + background-color: #f2f2f2; } -.App-link { - color: #61dafb; +table td img { + width: 100px; + border-radius: 50%; } -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } +.action-btn { + background-color: #dc3545; } diff --git a/src/App.js b/src/App.js index 3784575..2f1c296 100644 --- a/src/App.js +++ b/src/App.js @@ -1,23 +1,61 @@ -import logo from './logo.svg'; +// src/App.js + +import React, { useState } from 'react'; import './App.css'; +import contactsData from './contacts.json'; function App() { + const [contacts, setContacts] = useState(contactsData.slice(0, 5)); + const addRandomContact = () => { + const remainingContacts = contactsData.filter(contact => !contacts.map(c => c.id).includes(contact.id)); + const randomIndex = Math.floor(Math.random() * remainingContacts.length); + const randomContact = remainingContacts[randomIndex]; + setContacts(prevContacts => [...prevContacts, randomContact]); + }; + const sortByName = () => { + const sortedContacts = [...contacts].sort((a, b) => a.name.localeCompare(b.name)); + setContacts(sortedContacts); + }; + + const sortByPopularity = () => { + const sortedContacts = [...contacts].sort((a, b) => b.popularity - a.popularity); + setContacts(sortedContacts); + }; + + const deleteContact = (id) => { + const updatedContacts = contacts.filter(contact => contact.id !== id); + setContacts(updatedContacts); + }; + return (
- Edit src/App.js and save to reload.
-
| Picture | +Name | +Popularity | +Won an Oscar | +Won an Emmy | +|
|---|---|---|---|---|---|
| {contact.name} | +{contact.popularity.toFixed(2)} | +{contact.wonOscar ? '🏆' : null} | +{contact.wonEmmy ? '🏆' : null} | ++ |