commit all.
This commit is contained in:
parent
6ed0c48f4e
commit
3f6d7bd638
3 changed files with 134 additions and 0 deletions
17
script.js
Normal file
17
script.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
const toast = document.querySelector(".toast");
|
||||
const showToast = (goal) => {
|
||||
toast.textContent = `${goal} mode selected — your box is almost ready.`;
|
||||
toast.classList.add("show");
|
||||
window.setTimeout(() => toast.classList.remove("show"), 3200);
|
||||
};
|
||||
|
||||
document.querySelectorAll(".meal-card").forEach((card) => {
|
||||
const action = card.querySelector(".card-action");
|
||||
action.addEventListener("click", () => showToast(card.dataset.goal));
|
||||
card.addEventListener("keydown", (event) => {
|
||||
if ((event.key === "Enter" || event.key === " ") && event.target === card) {
|
||||
event.preventDefault();
|
||||
showToast(card.dataset.goal);
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue