add meal item form component
This commit is contained in:
parent
b2fcdfe8cd
commit
cf733097b8
@ -32,6 +32,7 @@ const DUMMY_MEALS = [
|
|||||||
const AvailableMeals = () => {
|
const AvailableMeals = () => {
|
||||||
const mealsList = DUMMY_MEALS.map((meal) => (
|
const mealsList = DUMMY_MEALS.map((meal) => (
|
||||||
<MealItem
|
<MealItem
|
||||||
|
id={meal.id}
|
||||||
key={meal.id}
|
key={meal.id}
|
||||||
name={meal.name}
|
name={meal.name}
|
||||||
description={meal.description}
|
description={meal.description}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import classes from "./MealItem.module.css";
|
import classes from "./MealItem.module.css";
|
||||||
|
import MealItemForm from "./MealItemForm";
|
||||||
|
|
||||||
const MealItem = (props) => {
|
const MealItem = (props) => {
|
||||||
const price = `$${props.price.toFixed(2)}`;
|
const price = `$${props.price.toFixed(2)}`;
|
||||||
@ -11,7 +12,7 @@ const MealItem = (props) => {
|
|||||||
<div className={classes.price}>{price}</div>
|
<div className={classes.price}>{price}</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
<MealItemForm id={props.id} />
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
23
src/components/Meals/MealItem/MealItemForm.js
Normal file
23
src/components/Meals/MealItem/MealItemForm.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import classes from "./MealItemForm.module.css";
|
||||||
|
import Input from "../../UI/Input";
|
||||||
|
|
||||||
|
const MealItemForm = (props) => {
|
||||||
|
return (
|
||||||
|
<form className={classes.form}>
|
||||||
|
<Input
|
||||||
|
label="Amount"
|
||||||
|
input={{
|
||||||
|
id: "amount_" + props.id,
|
||||||
|
type: "number",
|
||||||
|
min: "1",
|
||||||
|
max: "5",
|
||||||
|
step: "1",
|
||||||
|
defaultValue: "1",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<button>+ Add</button>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MealItemForm;
|
20
src/components/Meals/MealItem/MealItemForm.module.css
Normal file
20
src/components/Meals/MealItem/MealItemForm.module.css
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
.form {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form button {
|
||||||
|
font: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: #8a2b06;
|
||||||
|
border: 1px solid #8a2b06;
|
||||||
|
color: white;
|
||||||
|
padding: 0.25rem 2rem;
|
||||||
|
border-radius: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form button:hover,
|
||||||
|
.form button:active {
|
||||||
|
background-color: #641e03;
|
||||||
|
border-color: #641e03;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user