Repository navigation
Expand file tree
/
Copy pathmenu-visual.js
More file actions
5 lines (5 loc) · 2.28 KB
/
Copy pathmenu-visual.js
File metadata and controls
5 lines (5 loc) · 2.28 KB
1
2
3
4
5
const dishGallery={"Charred Cauliflower":["assets/menu-plates.png","Charred Cauliflower with saffron sauce and smoked almonds","01 / 09"],"Lotus Stem Chaat":["assets/dish-lotus.png","Crisp Lotus Stem Chaat with green mango, chilli and cultured cream","02 / 09"],"Forest Mushroom Kulcha":["assets/dish-kulcha.png","Forest Mushroom Kulcha with black garlic and morel butter","03 / 09"],"Coal-Roasted Pumpkin":["assets/menu-mains.png","Coal-roasted pumpkin with Kashmiri chilli, brown butter and millet","04 / 09"],"Jackfruit Galouti":["assets/dish-galouti.png","Jackfruit Galouti with sheermal and mint chutney","05 / 09"],"Nocturne Dal":["assets/dish-dal.png","Slow-cooked black lentils with smoked tomato","06 / 09"],"Burnt Mishti Doi":["assets/menu-sweet.png","Burnt Mishti Doi with nolen gur and puffed rice","07 / 09"],"Dark Chocolate Chikki":["assets/dish-chikki.png","Dark Chocolate Chikki with sesame, jaggery and vanilla bean cream","08 / 09"],"Saffron Milk Cake":["assets/dish-cake.png","Saffron Milk Cake with pistachio and citrus leaf","09 / 09"]};
const gallery=document.querySelector("#dish-night"),galleryImage=document.querySelector("#dish-image");
function selectDish(row){const name=row.querySelector("h3").textContent,item=dishGallery[name];if(!item)return;document.querySelectorAll(".dish").forEach(d=>d.classList.remove("selected"));row.classList.add("selected");gallery.classList.add("changing");setTimeout(()=>{galleryImage.src=item[0];galleryImage.alt=item[1];document.querySelector("#dish-title").innerHTML=name.toUpperCase().replace(" ","<br>");document.querySelector("#dish-description").textContent=row.querySelector("p").textContent;document.querySelector("#dish-price").textContent=row.querySelector("strong").textContent;document.querySelector("#dish-count").textContent=item[2];gallery.classList.remove("changing");gallery.scrollIntoView({behavior:"smooth",block:"start"})},180)}
function wireDishes(){document.querySelectorAll(".dish").forEach(row=>{row.tabIndex=0;row.setAttribute("role","button");row.setAttribute("aria-label","View "+row.querySelector("h3").textContent);row.onclick=()=>selectDish(row);row.onkeydown=e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();selectDish(row)}}})}
new MutationObserver(wireDishes).observe(document.querySelector(".dish-list"),{childList:true});wireDishes();