const { Button, PillTag, TextLink } = window.WaraqEnabDesignSystem_f0e2a0; const { useState, useEffect, useRef, useCallback } = React; /* Popular dishes shown in the slideshow. Each slide is a drop target: drag a photo onto it and it stays. Set video to a file you upload (e.g. "media/luqaimat.mp4") and that slide plays instead. */ const SHOW_SLIDES = [ { dish: ["mahashi", "vine-leaves-normal"], video: null }, { dish: ["mahashi", "harees-meat"], video: null }, { dish: ["varied-items", "luqaimat"], video: null }, { dish: ["mahashi", "chicken-musakhan"], video: null }, { dish: ["fattah", "fattah-vine-leaves-with-cheetos"], video: null }, { dish: ["varied-items", "tharid-traditional-arabic-chicken-and-vegetables"], video: null }, { dish: ["varied-items", "emirati-chebab-pancake-nutella"], video: null }, { dish: ["mahashi", "kushari"], video: null } ]; const SHOW_MS = 6000; function ShowSlide({ slide, index, active }) { const data = item(slide.dish[0], slide.dish[1]); const vid = useRef(null); /* only the slide on screen plays */ useEffect(() => { if (!vid.current) return; if (active) { const p = vid.current.play(); if (p && p.catch) p.catch(() => {}); } else { vid.current.pause(); vid.current.currentTime = 0; } }, [active]); return (
{slide.video ? : }
{data && (
{String(index + 1).padStart(2, "0")} / {String(SHOW_SLIDES.length).padStart(2, "0")}

{tn(data)}

)}
); } function Showcase() { const [at, setAt] = useState(0); const [paused, setPaused] = useState(false); const n = SHOW_SLIDES.length; const box = useRef(null); const touch = useRef(null); const go = useCallback((d) => setAt(v => (v + d + n) % n), [n]); /* arrow keys: anywhere once the slideshow has been used, always when focused */ useEffect(() => { const on = (e) => { if (e.metaKey || e.ctrlKey || e.altKey) return; const tag = (e.target.tagName || "").toLowerCase(); if (tag === "input" || tag === "textarea" || tag === "select") return; const inside = box.current && box.current.contains(document.activeElement); const onScreen = box.current && (() => { const r = box.current.getBoundingClientRect(); return r.top < innerHeight * 0.75 && r.bottom > innerHeight * 0.25; })(); if (!inside && !onScreen) return; if (e.key === "ArrowRight") { e.preventDefault(); go(1); } else if (e.key === "ArrowLeft") { e.preventDefault(); go(-1); } else if (e.key === "Home") { e.preventDefault(); setAt(0); } else if (e.key === "End") { e.preventDefault(); setAt(n - 1); } }; window.addEventListener("keydown", on); return () => window.removeEventListener("keydown", on); }, [go, n]); /* auto advance, unless a video is running the slide or the user is on it */ useEffect(() => { if (paused) return; if (SHOW_SLIDES[at].video) return; const timer = setTimeout(() => go(1), SHOW_MS); return () => clearTimeout(timer); }, [at, paused, go]); const start = (e) => { touch.current = e.touches[0].clientX; }; const end = (e) => { if (touch.current == null) return; const dx = e.changedTouches[0].clientX - touch.current; if (Math.abs(dx) > 45) go(dx < 0 ? 1 : -1); touch.current = null; }; return (
{t("See the full menu")}} />
setPaused(true)} onMouseLeave={() => setPaused(false)} onFocus={() => setPaused(true)} onBlur={() => setPaused(false)} onTouchStart={start} onTouchEnd={end}>
{SHOW_SLIDES.map((s, i) => )}
{!paused && !SHOW_SLIDES[at].video && }
{SHOW_SLIDES.map((s, i) => ( ))}

{t("Drag a photo onto a slide to replace it. It stays after a refresh.")}

); } Object.assign(window, { Showcase, SHOW_SLIDES });