Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16,613 changes: 16,613 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "assign2",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"react-select": "^4.3.1",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
17 changes: 17 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">

<head>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

</body>

</html>
44 changes: 44 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.App {
text-align: center;
display:flex;
flex-direction: row;
background-color: #FAFAFE;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
h1 ,h2 {
font-family: 'Quicksand';
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: right;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
56 changes: 56 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import './App.css';
import SideNav from './components/sideNav/SideNav'
import Items from './components/Items/items.js'
import Panel from './components/Panel/panel'
import { useState } from 'react'
export default function App() {
const [bucket, setBucket] = useState([
{
category: "Fruits",
items: [
{ label: "kiwi", q: 1 },
{ label: "WaterMelon", q: 1 }

]
},
{
category: "Fish",
items: [
{ label: "tuna ", q: 1 }

]
}
])
const [mainItems,setMainItems] = useState([
{ category: "Fish", elements: [{ id: 1, label: "tuna" }, { id: 2, label: "carp" }, { id: 3, label: "sardin" }] },
{ category: "Meat", elements: [{ id: 1, label: "chicken" }, { id: 2, label: "beef" }, { id: 3, label: "pork" }, { id: 4, label: "turkey" }] },
{ category: "Fruits", elements: [{ id: 1, label: "Avocado" }, { id: 2, label: "kiwi" }, { id: 3, label: "WaterMelon" }] }
])

const addToBucket=(category, newItem)=> {
let data = [...bucket];

let categoryIndex = data.findIndex((element) => element.category === category);
if (categoryIndex !== -1) {
let itemIndex = data[categoryIndex].items.findIndex((item) => item.label === newItem.label);
if (itemIndex !== -1) {
data[categoryIndex].items[itemIndex].q++;
} else {
data[categoryIndex].items.push({ label: newItem.label, q: 1 });
}
} else {
data.push({ category: category, items: [{ label: newItem.label, q: 1 }] });
}
setBucket(data);
}
const categories = mainItems.map(element => element.category)
return (
<div className="App">
<SideNav />
<Items items={mainItems} addToBucket={addToBucket} />
<Panel bucket={bucket} categories={categories} />
</div>
);
}


101 changes: 101 additions & 0 deletions src/components/Items/items.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(https://example.com/MaterialIcons-Regular.eot); /* For IE6-8 */
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url(https://example.com/MaterialIcons-Regular.woff2) format('woff2'),
url(https://example.com/MaterialIcons-Regular.woff) format('woff'),
url(https://example.com/MaterialIcons-Regular.ttf) format('truetype');
}
.wrapper {
width : 900px;
margin : 30px 80px;
margin-right : 10px;
}
.categoryWrapper {
margin : 20px 0 ;
}
.categoryWrapper h1 {
text-align: left;
margin :10px 10px;
font-size: 22px;
}

.itemsWrapper {
width: 100%;
display: inline-flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: start;
}
.itemBtn {
background: #FFFFFF;
width: 182px;
height: fit-content;
margin: 10px 10px;

box-shadow: 0px 2px 12px rgba(0, 0, 0, 0.05);
border-radius:12px ;
border : none;
align-items: center;
display: inline-flex;
justify-content: space-around;
cursor : pointer
}
.itemsWrapper :hover {
box-shadow: 0px 15px 25px rgba(0, 0, 0, 0.05);

}
.itemBtn h2 {
font-size: 18px;
}
.itemBtn span {
margin-left: 10px;
margin-right: 15;
color : #C1C1C4;
width:14px;
}

/* HEADER */
.header {
display : flex;
flex-direction: row;
height : fit-content;
align-items: center;
margin-bottom:57px;
}
.header h2 {
width :450px;
text-align: start;
font-family: Quicksand;
font-style: normal;
font-weight: bold;
font-size: 24px;
line-height: 32px;
}
.header h2 span {
color : #F9A109;
}

.header div {
display : inline-flex;
align-items: right;
}
.search{
background: #FFFFFF;
box-shadow: 0px 2px 12px rgba(0, 0, 0, 0.04);
border-radius: 12px;
padding : 16px;
}
.search input {
border : none;
font-style: normal;
font-weight: 500;
font-size: 14px;
line-height: 17px;
color: #BDBDBD;
margin-left:23px;
}

49 changes: 49 additions & 0 deletions src/components/Items/items.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import './items.css'
const Items=(props) =>{
let items = props.items

const addToBucket=(category, item) =>{
props.addToBucket(category, item);
}
return (
<div className="wrapper">

<div className="header">
<h2><span>Shoppingify</span></h2>
<div className="search">
<span className="material-icons"></span>
<input ></input>
</div>
</div>
{
items.map((element,index) => {
return <div className="categoryWrapper" key={index}>

<h1>{element.category}</h1>

<div className="itemsWrapper">
{
element.elements.map((item,iIndex) => {
return (
<button className="itemBtn" onClick={() => { addToBucket(element.category, item) }} key={iIndex}>
<h2>{item.label}</h2>
<span className="material-icons"> add</span>
</button>
)

})
}
</div>


</div>
})

}
</div>
)

}


export default Items;
5 changes: 5 additions & 0 deletions src/components/Panel/panel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
div {
padding : 5px;
display : flex;
flex-direction: column;
}
23 changes: 23 additions & 0 deletions src/components/Panel/panel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Basket from "../basket/Basket";
import AddItem from "../addItem/addItem";
import { useState } from "react";
import './panel.css'


const Panel=(props)=> {
let bucket = props.bucket
let categories = props.categories
const [addNew, setAddNew] = useState(false);
const addNewItem=()=> {
setAddNew(true);
}


return (
<div >
{addNew ? <AddItem categories={categories} cancel={() => setAddNew(false)} /> : <Basket bucket={bucket} addNewItem={addNewItem} />}
</div>
)
}

export default Panel;
Loading