From a2c64f49ed8c2401cbb7ccc59638bece0e39a037 Mon Sep 17 00:00:00 2001
From: VijayaAdamane <95336658+VijayaAdamane@users.noreply.github.com>
Date: Sun, 18 Feb 2024 09:39:09 +0530
Subject: [PATCH 1/2] App.js
---
src/App.js | 111 ++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 97 insertions(+), 14 deletions(-)
diff --git a/src/App.js b/src/App.js
index 3784575..eaba1ce 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,23 +1,106 @@
+import { useState } from 'react';
+
import logo from './logo.svg';
import './App.css';
+import contactsFile from './contacts.json';
function App() {
+
+ const [contacts, setContacts] = useState(contactsFile.slice(0, 5));
+
+ function wonOscar(contact) {
+ const oscar = contact.wonOscar;
+
+ return oscar;
+ }
+
+ function wonEmmy(contact) {
+ const emmy = contact.wonEmmy;
+
+ return emmy;
+ }
+
+ function addRandomContact() {
+ //select a random contact from the remaining contacts
+ const randomIndex = Math.floor((Math.random()) * (contactsFile.length - 5));
+ const randomContact = [...contactsFile.slice(5)][randomIndex];
+
+ setContacts((prevContacts) => [...prevContacts, randomContact]);
+ }
+
+ function sortByPopularity() {
+ const sortedArrayByPopularity = contacts.toSorted((a, b) => {
+ return b.popularity - a.popularity;
+ });
+ setContacts(sortedArrayByPopularity);
+ }
+
+ function sortByName() {
+ const sortedArrayByName = contacts.toSorted((a, b) => {
+ return a.name.localeCompare(b.name);
+ });
+ setContacts(sortedArrayByName);
+ }
+
+ function deleteContact(event) {
+ const key = event.target.getAttribute('data-key');
+ console.log(key);
+ let filteredArray = contacts.filter((contact) => {
+ return contact.id !== key;
+ });
+ setContacts(filteredArray);
+ }
+
return (
-
+
+
Contact Manager
+
+
+
+
+
+
+
+
+
+
+ | Picture |
+ Name |
+ Popularity |
+ Oscar |
+ Emmy |
+ Action |
+
+
+
+
+ {contacts.map((contact) => {
+ return (
+
+
+ | {contact.name} |
+ {contact.popularity} |
+
+
+ {wonOscar(contact) ? '🏆' : ''}
+ |
+
+
+
+ {wonEmmy(contact) ? '🏆' : ''}
+ |
+
+
+
+
+ |
+
+
+ )
+ })}
+
+
);
}
From 2eedcd75b46ffcec753a79c1b4ace6d8bd592fef Mon Sep 17 00:00:00 2001
From: VijayaAdamane <95336658+VijayaAdamane@users.noreply.github.com>
Date: Sun, 18 Feb 2024 09:40:15 +0530
Subject: [PATCH 2/2] App.css
---
src/App.css | 92 +++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 69 insertions(+), 23 deletions(-)
diff --git a/src/App.css b/src/App.css
index 74b5e05..38e646f 100644
--- a/src/App.css
+++ b/src/App.css
@@ -1,38 +1,84 @@
.App {
+ display: flex;
+ flex-flow: column nowrap;
+
text-align: center;
}
-.App-logo {
- height: 40vmin;
- pointer-events: none;
+.appHeader {
+ display: flex;
+ justify-content: space-between;
+
+ /* background-color: rgb(189, 189, 189); */
+ /* background-color: rgb(242, 176, 190); */
+ /* background-color: teal; */
+ /* background-color: rgb(225, 173, 255); */
+ background-image: url('./images/background.jpg');
+
+ padding-top: 25px;
+ padding-bottom: 25px;
+ box-sizing: border-box;
+}
+
+.appHeading {
+ color: whitesmoke;
+ font-family: 'Baskerville', fantasy;
+ font-size: 50px;
+
+ margin: 10px;
+}
+
+.buttons {
+ padding-top: 12.5px;
+}
+
+.button {
+ margin: 10px;
}
-@media (prefers-reduced-motion: no-preference) {
- .App-logo {
- animation: App-logo-spin infinite 20s linear;
- }
+.contactsTable {
+ display: flex;
+ flex-flow: column nowrap;
+ justify-content: space-around;
+
+ margin-top: 10px;
}
-.App-header {
- background-color: #282c34;
- min-height: 100vh;
+.aRow {
display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- font-size: calc(10px + 2vmin);
+ flex-flow: row nowrap;
+ justify-content: space-between;
+}
+
+.tableHeader {
+ /* background-color: rgb(89, 0, 255); */
+ /* background-color: rgb(15, 222, 233); */
+ background-color: rgb(23, 159, 159);
color: white;
+
+ font-size: 20px;
+}
+
+
+.contactColumn {
+ margin: 5px;
+ width: 1300px;
+ text-align: center;
+}
+
+.headerColumn {
+ width: 1300px;
+ text-align: center;
+ border: solid white 2px;
}
-.App-link {
- color: #61dafb;
+.contactRow {
+ margin: 5px;
}
-@keyframes App-logo-spin {
- from {
- transform: rotate(0deg);
- }
- to {
- transform: rotate(360deg);
- }
+.picture {
+ width: 50px;
+ height: auto;
+
+ border-radius: 50%;
}