-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86a51bf
commit 4f42dbe
Showing
15 changed files
with
1,341 additions
and
89 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,147 @@ | ||
.App { | ||
text-align: center; | ||
*{ | ||
margin: 0px; | ||
} | ||
|
||
.App-logo { | ||
height: 40vmin; | ||
pointer-events: none; | ||
.item-wrapper{ | ||
height: 200px; | ||
width: 200px; | ||
background-color:rgb(250, 250, 196); | ||
border-radius: 5px; | ||
margin: 50px; | ||
box-shadow: 1px 1px 12px 5px rgb(222, 243, 191); | ||
/* border-style: ridge; | ||
border-color:rgb(211, 241, 163); | ||
border-width: 5px; | ||
*/ | ||
} | ||
.item-wrapper:hover { | ||
box-shadow:1px 1px 6px 5px rgb(200, 236, 147); | ||
background-color:rgb(241, 241, 141); | ||
border-radius: 10px; | ||
} | ||
.Home-wrapper{ | ||
display:flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
margin-top:30px; | ||
|
||
} | ||
.item-image{ | ||
height: 150px; | ||
width: 150px; | ||
border-radius:50%; | ||
margin-top:25px; | ||
margin-left: 25px; | ||
|
||
} | ||
.item-name{ | ||
text-align: center; | ||
color:black; | ||
text-decoration: none; | ||
} | ||
.header-wrapper{ | ||
background-color: palevioletred; | ||
|
||
height: 70px; | ||
text-align:center; | ||
padding-top:20px; | ||
} | ||
h1{ | ||
color: blueviolet; | ||
} | ||
.cart-icon{ | ||
float:right; | ||
color: white; | ||
margin-right: 20px; | ||
|
||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
} | ||
.product-wrapper>h2{ | ||
text-align:center; | ||
margin-top:20px; | ||
} | ||
|
||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
display: flex; | ||
.product-item-wrapper{ | ||
display:flex; | ||
flex-direction: row; | ||
/* justify-content: center; */ | ||
border-bottom:2px dotted; | ||
padding-top: 25px; | ||
} | ||
.product-image{ | ||
height: 150px; | ||
width: 150px; | ||
|
||
} | ||
.product-image>img{ | ||
height: 120px; | ||
width: 150px; | ||
border-radius:50%; | ||
|
||
} | ||
.product-details{ | ||
width:70%; | ||
display:flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
padding-left:10px; | ||
align-content: space-between; | ||
} | ||
.product-btn{ | ||
width:20%; | ||
height: 40px; | ||
margin-top: 20px; | ||
color: white; | ||
background-color:palevioletred; | ||
border: 1px solid rgb(231, 84, 133); | ||
|
||
} | ||
.product-btn:hover{ | ||
border:blueviolet 2px solid; | ||
|
||
} | ||
.product-btn:active{ | ||
color:rgb(238, 9, 85); | ||
} | ||
.product-description{ | ||
color:rgb(163, 155, 155); | ||
} | ||
.cart-title{ | ||
font-size: 30px; | ||
font-style:bold; | ||
margin-left:45%; | ||
|
||
} | ||
.place-order{ | ||
margin-right: 10px; | ||
margin-top: 5px; | ||
text-decoration: none; | ||
float: right; | ||
} | ||
.place-order:hover{ | ||
color:red; | ||
} | ||
.empty-cart{ | ||
color:red; | ||
margin-left: 45%; | ||
|
||
.App-link { | ||
color: #61dafb; | ||
} | ||
.price-card{ | ||
margin-left:30px; | ||
margin-top:10px; | ||
font-size:25px; | ||
} | ||
.cancle-btn{ | ||
width: 40px; | ||
height: 25px; | ||
border-radius:50%; | ||
border:white; | ||
float: right; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
.triangle-left{ | ||
margin-right: 5px; | ||
} | ||
.triangle-right{ | ||
margin-left: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,49 @@ | ||
import logo from './logo.svg'; | ||
|
||
import './App.css'; | ||
import React,{useState, useEffect} from 'react'; | ||
import {BrowserRouter,Routes,Route} from 'react-router-dom'; | ||
import Pizza from './Components/Pizza'; | ||
import Burger from './Components/Burger'; | ||
import Home from './Components/Home'; | ||
import Cart from './Components/Cart'; | ||
import Header from './Components/Header'; | ||
import axios from 'axios'; | ||
|
||
let url="https://fod-app.herokuapp.com/food"; | ||
export const FoodContext= React.createContext(); | ||
function App() { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Edit <code>src/App.js</code> and save to reload. | ||
</p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
</header> | ||
</div> | ||
); | ||
let [data,setData]=useState([]); | ||
let [cart,setCart]=useState([]); | ||
let [cartValue,setCartValue]=useState(0); | ||
|
||
useEffect(()=>{ | ||
getData(); | ||
},[]) | ||
|
||
let getData=async()=>{ | ||
let response= await axios.get(url); | ||
//console.log(response.data); | ||
setData(response.data); | ||
} | ||
|
||
return <> | ||
<BrowserRouter> | ||
<FoodContext.Provider value={{data,cart,setCart,cartValue,setCartValue}}> | ||
<Header/> | ||
<Routes> | ||
<Route path='/pizza' element={<Pizza/>}/> | ||
<Route path='/burger' element={<Burger/>}/> | ||
<Route path='/cart' element={<Cart/>}/> | ||
<Route path='/' element={<Home/>}/> | ||
</Routes> | ||
|
||
</FoodContext.Provider> | ||
|
||
|
||
</BrowserRouter> | ||
|
||
|
||
</> | ||
} | ||
|
||
export default App; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import {useContext} from 'react'; | ||
import {FoodContext} from '../App'; | ||
import {useState, useEffect} from 'react'; | ||
import {useNavigate} from 'react-router-dom'; | ||
|
||
function Burger() { | ||
let context = useContext(FoodContext); | ||
let [products,setProducts]=useState([]) | ||
let navigate=useNavigate(); | ||
let getData=()=>{ | ||
if(context.data.length>0){ | ||
setProducts(context.data[1].subItemsData.subItems) | ||
} | ||
else{ | ||
navigate('/') | ||
} | ||
} | ||
|
||
useEffect(()=>{getData()},[]) | ||
|
||
return <div className="product-wrapper"> | ||
<h2>Tasty Burger</h2> | ||
{ | ||
products.map((b,i)=>{ | ||
return <div className="product-item-wrapper" key={i}> | ||
<div className="product-details"> | ||
<b>{b.name}</b> | ||
<div className="product-price">₹ {b.price}</div> | ||
<div className="product-description">{b.description}</div> | ||
<button className="product-btn" onClick={()=>{ | ||
context.cart.push(b); | ||
context.setCartValue(context.cart.length) | ||
}}>Add to cart</button> | ||
</div> | ||
|
||
<div className="product-image"> | ||
<img src={b.image} alt={b.name}/> | ||
</div> | ||
|
||
</div> | ||
}) | ||
} | ||
</div> | ||
} | ||
|
||
export default Burger | ||
|
Oops, something went wrong.