-
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.
Creating components files inside components folder
- Loading branch information
1 parent
a602341
commit 183d148
Showing
7 changed files
with
136 additions
and
174 deletions.
There are no files selected for viewing
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,28 @@ | ||
import Order from './Order' | ||
|
||
function Footer() { | ||
const hour = new Date().getHours() | ||
const openHour = 12 | ||
const closeHour = 22 | ||
const isOpen = hour >= openHour && hour <= closeHour | ||
console.log(isOpen) | ||
|
||
// if (hour >= openHour && hour <= closeHour) alert("We're currently open!") | ||
// else alert("Sorry we're close") | ||
|
||
return ( | ||
<footer className="footer"> | ||
{isOpen ? ( | ||
<Order closeHour={closeHour} openHour={openHour} /> | ||
) : ( | ||
<p> | ||
We're happy to welcome you between {openHour}:00 and {closeHour}:00. | ||
</p> | ||
)} | ||
{/* {new Date().toLocaleTimeString()}. We're currently open */} | ||
</footer> | ||
) | ||
// return React.createElement('footer', null, "We're currently open!") | ||
} | ||
|
||
export default Footer |
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,9 @@ | ||
function Header() { | ||
return ( | ||
<header className="header"> | ||
<h1>Fast React Pizza Co.</h1> | ||
</header> | ||
) | ||
} | ||
|
||
export default Header |
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,47 @@ | ||
import { pizzaData } from '../data' | ||
import Pizza from './Pizza' | ||
|
||
function Menu() { | ||
const pizzas = pizzaData | ||
// const pizzas = [] | ||
const numPizzas = pizzas.length | ||
|
||
return ( | ||
<main className="menu"> | ||
<h2>Our Menu</h2> | ||
|
||
{numPizzas > 0 ? ( | ||
<> | ||
<p> | ||
Authentic Italian cuisine. 6 creative dishes to choose from. All | ||
from our stone oven, all organic, all delicious. | ||
</p> | ||
|
||
<ul className="pizzas"> | ||
{/* Another aproach of iterating over the data list. */} | ||
{pizzas.map((pizza) => ( | ||
<Pizza pizzaObj={pizza} key={pizza.id} /> | ||
))} | ||
</ul> | ||
</> | ||
) : ( | ||
<p>We're still working in our menu. Please come back later</p> | ||
)} | ||
|
||
{/* <Pizza | ||
name="Pizza Spinaci" | ||
ingredients="Tomato, mozarella, spinach, and ricotta cheese" | ||
photoName="pizzas/spinaci.jpg" | ||
price={10} | ||
/> | ||
<Pizza | ||
name="Pizza Funghi" | ||
ingredients="Tomato, mushrooms" | ||
price={12} | ||
photoName="pizzas/funghi.jpg" | ||
/> */} | ||
</main> | ||
) | ||
} | ||
|
||
export default Menu |
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,13 @@ | ||
function Order({ closeHour, openHour }) { | ||
return ( | ||
<div className="order"> | ||
<p> | ||
We're open from {openHour}:00 until {closeHour}:00. Come visit us or | ||
order online. | ||
</p> | ||
<button className="btn">Order</button> | ||
</div> | ||
) | ||
} | ||
|
||
export default Order |
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,35 @@ | ||
//Pizza component receiving props from Menu component | ||
function Pizza({ pizzaObj }) { | ||
return ( | ||
<li className={`pizza ${pizzaObj.soldOut ? 'sold-out' : ''}`}> | ||
<img src={pizzaObj.photoName} alt={pizzaObj.name} /> | ||
<div> | ||
<h3>{pizzaObj.name}</h3> | ||
<p>{pizzaObj.ingredients}</p> | ||
<span>{pizzaObj.soldOut ? 'SOLD OUT' : pizzaObj.price}</span> | ||
</div> | ||
</li> | ||
) | ||
} | ||
|
||
//Pizza component with map functionality inside. | ||
// function Pizza() { | ||
// return ( | ||
// <li className="pizza"> | ||
// {pizzaData.map((data) => { | ||
// return ( | ||
// <div key={data.id}> | ||
// <img src={data.photoName} alt={data.name} /> | ||
// <div> | ||
// <h3>{data.name}</h3> | ||
// <p>{data.ingredients}</p> | ||
// <span>{data.price}</span> | ||
// </div> | ||
// </div> | ||
// ) | ||
// })} | ||
// </li> | ||
// ) | ||
// } | ||
|
||
export default Pizza |
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