Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions src/app/meal/detail/detail.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
.detailPage {
padding: 24px;
background: #fff;
min-height: 100vh;
}

.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;

.backBtn {
background: none;
font-size: 20px;
cursor: pointer;
}

.spacer {
width: 24px;
}
}

.timeKcalWrap {
display: flex;
justify-content: space-between;
margin-bottom: 16px;

.mealTime {
font-weight: 600;
}

.kcalInfo {
display: flex;
align-items: center;
gap: 4px;

.kcalText {
font-size: 14px;
}
}
}

.imageWrap {
text-align: center;
position: relative;

.mealImage {
width: 200px;
border-radius: 12px;
margin-bottom: 20px;
}
}

.foodList {
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: center;
margin-bottom: 16px;

.foodButton {
padding: 6px 12px;
border-radius: 20px;
font-size: 14px;
border: 1px solid #ccc;
}

.success {
border-color: #000;
}

.fail {
border-color: #f00;
color: #f00;
}

.close {
margin-left: 4px;
}
}

.addButton {
background: none;
border: 1px solid #aaa;
padding: 6px 12px;
border-radius: 20px;
margin: 10px auto;
display: block;
font-size: 14px;
}

.nutrientBox {
padding: 20px;

margin-bottom: 24px;

.kcalRow {

margin-bottom: 12px;

span {
font-size: 14px;
color: #D9D9D9;
}

.kcalValue {
display: flex;
align-items: center;
gap: 30px;

font-size: 16px;
font-weight: 800;
line-height: 24px;
width: 135px;
letter-spacing: 0;
position: relative;
border: 1px solid #eee;
border-radius: 12px;
background-color: #fafafa;

padding: 10px 16px;
margin-top: 20px;
align-items: center;

.kcalNumber {
font-size: 16px;
font-weight: 800;
color: #000;

}

.kcalUnit {

font-size: 16px;
font-weight: 700;
color: #c4c4c4;
}



}
}

.macroRow {
display: flex;
justify-content: space-between;
gap: 30px;

.nutrient {
flex: 1;

p:first-child {
font-size: 13px;
color: #666;
margin-bottom: 6px;
}

.macroValue {
font-size: 16px;
font-weight: 800;
position: relative;
border: 1px solid #eee;
border-radius: 12px;
background-color: #fafafa;
padding: 10px 16px;
line-height: 24px;
letter-spacing: 0;
display: flex;
align-items: center;
gap: 30px;


span {
font-size: 14px;
color: #D9D9D9;
}
}
}
}
}


.completeBtn {
width: 100%;
margin-top: 24px;
padding: 14px;
font-size: 16px;
background: #ccc;
color: #fff;
border: none;
border-radius: 30px;
cursor: pointer;
}

108 changes: 108 additions & 0 deletions src/app/meal/detail/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
"use client";

import { useSearchParams, useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import styles from "./detail.module.scss";
import Balloon from "@/components/common/balloon/balloon";
import GaugeIcon, { GaugeStep } from "@/components/common/caloriesgauge/caloriesgauge";

const calorieGoals: Record<string, number> = {
아침: 435,
점심: 700,
저녁: 550,
};

export default function MealDetailPage() {
const searchParams = useSearchParams();
const router = useRouter();
const mealType = searchParams.get("type") || "아침";

const [imageUrl, setImageUrl] = useState("");
const [foods, setFoods] = useState<string[]>([]);
const [followedPlan, setFollowedPlan] = useState(true);

useEffect(() => {
const savedImage = localStorage.getItem(`mealImage-${mealType}`) || "";
const savedFoods = JSON.parse(localStorage.getItem(`mealFoods-${mealType}`) || "[]");

setImageUrl(savedImage);
setFoods(savedFoods);
setFollowedPlan(!!savedImage && savedFoods.length > 0);
}, [mealType]);

const handleAddOtherFoods = () => {
router.push(`/meal/search?type=${mealType}`);
};

const goal = calorieGoals[mealType] || 0;
const kcal = followedPlan ? goal : "?";

// 게이지 단계 계산
const step = followedPlan ? Math.floor((goal / 1445) * 8) : 0;
const gaugeStep = Math.max(0, Math.min(8, step)) as GaugeStep;

return (
<div className={styles.detailPage}>
<header className={styles.header}>
<button className={styles.backBtn} onClick={() => router.back()}> ← </button>
<h2>{mealType}</h2>
<div className={styles.spacer} />
</header>

<div className={styles.timeKcalWrap}>
<span className={styles.mealTime}>{mealType} 9:00</span>
<div className={styles.kcalInfo}>
<GaugeIcon step={gaugeStep} />
<span className={styles.kcalText}>
{followedPlan ? goal : "?"}/{goal}
</span>
</div>
</div>

<div className={styles.imageWrap}>
<Balloon text={followedPlan ? "식단을 잘 지켰어요!" : "다른 음식을 먹었어요"} />
<img src={imageUrl || "/icons/placeholder.png"} alt="식단 이미지" className={styles.mealImage} />
</div>

<div className={styles.foodList}>
{foods.map((food, idx) => (
<button key={idx} className={`${styles.foodButton} ${followedPlan ? styles.success : styles.fail}`}>
{food}
{!followedPlan && <span className={styles.close}>✕</span>}
</button>
))}
</div>

<button className={styles.addButton} onClick={handleAddOtherFoods}>
다른 음식 추가 +
</button>

<div className={styles.nutrientBox}>
<div className={styles.kcalRow}>
<span>총 칼로리</span>
<div className={styles.kcalValue}>{kcal} <span>kcal</span></div>
</div>
<div className={styles.macroRow}>
<div className={styles.nutrient}>
<p>탄수화물</p>
<p className={styles.macroValue}>{followedPlan ? "12.8" : "?"} <span>g</span></p>
</div>
<div className={styles.nutrient}>
<p>단백질</p>
<p className={styles.macroValue}>{followedPlan ? "6.5" : "?"} <span>g</span></p>
</div>
<div className={styles.nutrient}>
<p>지방</p>
<p className={styles.macroValue}>{followedPlan ? "5" : "?"} <span>g</span></p>
</div>
</div>
</div>

{!followedPlan && (
<button className={styles.completeBtn} onClick={handleAddOtherFoods}>
완료
</button>
)}
</div>
);
}
6 changes: 6 additions & 0 deletions src/app/meal/layout.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.container {
font-size: 1.6rem;
min-height: 100vh;
height: 100%;
padding-top: $header-height;
}
6 changes: 6 additions & 0 deletions src/app/meal/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from "react"
import styles from "./layout.module.scss"

export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
return <div className={styles.container}>{children}</div>
}
38 changes: 38 additions & 0 deletions src/app/meal/page.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@


/* 캘린더 */
.diet_calendar {
margin-top: 16px;
}

/* 식단 요약 */
.summarySection {
margin-top: 24px;
padding: 15px;
padding-bottom: 32px;
}

.summaryTitleWrap {
display: flex;
align-items: baseline;
justify-content: space-between;
}

.summaryTitle {
font-size: 20px;
font-weight: 600;
}

.kcalCount {
font-size: 14px;
color: #888;
padding-left: 10px;
}

/* 식단 카드 */
.mealsSection {
display: flex;
flex-direction: column;
//gap: 16px;
}

Loading