// Recipe detail — hero, TL;DR, ingredients with servings slider, steps with timer, FAQ
const RecipeDetail = ({ recipe, onBack, mobile = false }) => {
const r = recipe || window.RECIPES[0];
const [servings, setServings] = React.useState(r.servings);
const [checked, setChecked] = React.useState(new Set());
const [timer, setTimer] = React.useState(null); // { stepN, remaining }
const [openFaq, setOpenFaq] = React.useState(0);
React.useEffect(() => {
if (!timer) return;
const id = setInterval(() => {
setTimer(t => {
if (!t) return null;
if (t.remaining <= 1) return null;
return { ...t, remaining: t.remaining - 1 };
});
}, 1000);
return () => clearInterval(id);
}, [timer]);
const ratio = servings / r.servings;
const ingredients = [
{ name: '雞蛋', qty: 3, unit: '顆' },
{ name: '中型番茄', qty: 2, unit: '顆' },
{ name: '洋蔥', qty: 0.5, unit: '顆' },
{ name: '白米飯', qty: 2, unit: '碗' },
{ name: '蔥花', qty: 1, unit: '小把' },
{ name: '生抽', qty: 1, unit: '茶匙' },
{ name: '糖', qty: 0.5, unit: '茶匙' },
{ name: '鹽', qty: null, unit: '少許' },
];
const steps = window.STEPS_TOMATO_EGG;
const W = mobile ? 'm' : 'd';
const fmt = (s) => `${Math.floor(s/60)}:${String(s%60).padStart(2,'0')}`;
return (
TL;DR · 重點摘要
- 快手 15 分鐘完成,一鍋出,不用洗第二個鍋。
- 每份 320 大卡,蛋白質 18g,適合上班族午餐便當。
- 關鍵技巧:蛋炒七分熟先盛起,回鍋時才不會老。
- 缺番茄醬?用 2 顆熟番茄 + 1 茶匙糖 + 半茶匙白醋 自製。
時間15 分
份量{r.servings} 人
熱量320 卡
難度★ 新手
飲食素食
主料番茄 · 蛋
食材清單
準備這些
份量
{servings} 人份
數量已自動換算
{ingredients.map((i, idx) => (
- {
const n = new Set(checked);
n.has(idx) ? n.delete(idx) : n.add(idx);
setChecked(n);
}}>
{checked.has(idx) && }
{i.name}
{i.qty !== null ? {(i.qty * ratio).toFixed(i.qty < 1 ? 1 : 0).replace(/\.0$/,'')} : null} {i.unit}
))}
烹飪步驟
5 步上桌
{steps.map(s => (
-
{String(s.n).padStart(2,'0')}
{s.text}
{s.time && (
)}
))}
主編小貼士
讓這道菜更好吃
炒蛋時火不能太小,油溫要熱、蛋液下鍋立刻起泡,這樣蛋花才會蓬鬆。下番茄前可以先把鍋邊擦一下、補一點油,番茄出汁時才不會黏鍋。
— 主編 · 林書宇
營養資訊
每份提供
{[['熱量','320','kcal'],['蛋白質','18','g'],['碳水','42','g'],['脂肪','9','g'],['糖','6','g'],['鈉','480','mg']].map(([n,v,u])=>(
{v}{u}{n}
))}
常見問題
FAQ
{[
['這道菜可以提前做嗎?','可以,蛋液與番茄分別炒好後冷藏,吃前快速回炒 30 秒即可。建議當天食用,風味最佳。'],
['冷藏可以保存多久?','建議 2 天內食用完畢。盛盒冷藏前先放涼,避免水氣回潮。'],
['沒有番茄醬可以做嗎?','可以。用 2 顆熟番茄 + 1 茶匙糖 + 半茶匙白醋 慢炒到出汁,效果接近。'],
['吃素的可以做嗎?','可以,本食譜本身為素食(含蛋)。如需純素,蛋可換成豆腐丁。'],
].map(([q,a],i)=>(
setOpenFaq(openFaq===i?-1:i)}>
{q}
{openFaq===i &&
{a}
}
))}
延伸閱讀
類似的料理
{window.RECIPES.slice(1,5).map(x=>)}
);
};
window.RecipeDetail = RecipeDetail;