-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: checkbox state gets lost when toggling between ingredientsinstru…
…ctions (#231) * update paddings * add useState for checkboxes * fix styling for section title * no toggle from sm screens
- Loading branch information
1 parent
18d740f
commit 687a945
Showing
4 changed files
with
170 additions
and
62 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
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Checkbox, List } from "@mantine/core"; | ||
|
||
type RenderedIngredientsProps = { | ||
recipe: UserRecipe; | ||
checkboxStates: boolean[]; | ||
onCheckboxChange: (index: number, checked: boolean) => void; | ||
}; | ||
|
||
export default function RenderedIngredients({ | ||
recipe, | ||
checkboxStates, | ||
onCheckboxChange, | ||
}: RenderedIngredientsProps) { | ||
return ( | ||
<List listStyleType="none" spacing="xs"> | ||
{recipe.ingredients.map((ingredient, index) => { | ||
return ( | ||
<List.Item | ||
styles={{ | ||
itemWrapper: { | ||
display: "inline", | ||
}, | ||
}} | ||
key={index} | ||
> | ||
<Checkbox | ||
size="md" | ||
checked={checkboxStates[index]} | ||
onChange={(event) => | ||
onCheckboxChange(index, event.currentTarget.checked) | ||
} | ||
label={ | ||
<span | ||
style={{ | ||
opacity: checkboxStates[index] ? 0.5 : 1, | ||
}} | ||
> | ||
{ingredient} | ||
</span> | ||
} | ||
/> | ||
</List.Item> | ||
); | ||
})} | ||
</List> | ||
); | ||
} |
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