add meal item component
This commit is contained in:
parent
0ab7478690
commit
c4192ced47
@ -1,4 +1,6 @@
|
||||
import classes from "./AvailableMeals.module.css";
|
||||
import Card from "../UI/Card";
|
||||
import MealItem from "./MealItem/MealItem";
|
||||
|
||||
const DUMMY_MEALS = [
|
||||
{
|
||||
@ -28,11 +30,20 @@ const DUMMY_MEALS = [
|
||||
];
|
||||
|
||||
const AvailableMeals = () => {
|
||||
const mealsList = DUMMY_MEALS.map((meal) => <li>{meal.name}</li>);
|
||||
const mealsList = DUMMY_MEALS.map((meal) => (
|
||||
<MealItem
|
||||
key={meal.id}
|
||||
name={meal.name}
|
||||
description={meal.description}
|
||||
price={meal.price}
|
||||
/>
|
||||
));
|
||||
|
||||
return (
|
||||
<section className={classes.meals}>
|
||||
<ul>{mealsList}</ul>
|
||||
<Card>
|
||||
<ul>{mealsList}</ul>
|
||||
</Card>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
20
src/components/Meals/MealItem/MealItem.js
Normal file
20
src/components/Meals/MealItem/MealItem.js
Normal file
@ -0,0 +1,20 @@
|
||||
import classes from "./MealItem.module.css";
|
||||
|
||||
const MealItem = (props) => {
|
||||
const price = `$${props.price.toFixed(2)}`;
|
||||
|
||||
return (
|
||||
<li className={classes.meal}>
|
||||
<div>
|
||||
<h3>{props.name}</h3>
|
||||
<div className={classes.description}>{props.description}</div>
|
||||
<div className={classes.price}>{price}</div>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
};
|
||||
|
||||
export default MealItem;
|
22
src/components/Meals/MealItem/MealItem.module.css
Normal file
22
src/components/Meals/MealItem/MealItem.module.css
Normal file
@ -0,0 +1,22 @@
|
||||
.meal {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 1rem;
|
||||
padding-bottom: 1rem;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.meal h3 {
|
||||
margin: 0 0 0.25rem 0;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.price {
|
||||
margin-top: 0.25rem;
|
||||
font-weight: bold;
|
||||
color: #ad5502;
|
||||
font-size: 1.25rem;
|
||||
}
|
@ -4,8 +4,8 @@ import AvailableMeals from "./AvailableMeals";
|
||||
const Meals = () => {
|
||||
return (
|
||||
<>
|
||||
<AvailableMeals />
|
||||
<MealsSummary />
|
||||
<AvailableMeals />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user