add meal item component

This commit is contained in:
oscar 2023-03-18 12:12:59 +13:00
parent 0ab7478690
commit c4192ced47
4 changed files with 56 additions and 3 deletions

View File

@ -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>
);
};

View 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;

View 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;
}

View File

@ -4,8 +4,8 @@ import AvailableMeals from "./AvailableMeals";
const Meals = () => {
return (
<>
<AvailableMeals />
<MealsSummary />
<AvailableMeals />
</>
);
};