Skip to content

Commit 26b22cb

Browse files
authored
feat: create CalendarItem Component
2 parents ae3a91f + cfd8bc4 commit 26b22cb

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/app/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Navbar from "@/components/Navbar";
33
import RecipeSummary from "@/components/RecipeSummary";
44
import WeeklyMenu from "@/components/WeeklyMenu";
55
import ComboCard from "@/components/ComboCard";
6+
import CalendarRecipeItem from "@/components/CalendarRecipeItem";
67

78
export default function Home() {
89
const today = new Date();
@@ -26,6 +27,9 @@ export default function Home() {
2627
<RecipeSummary id={"recipe_test_001"} />
2728
<RecipeSummary id={"mango"} />
2829
<RecipeSummary id={"masdf"} />
30+
<div className="w-100">
31+
<CalendarRecipeItem name="Spaghetti Bolognese" calories={850} servingSize="1 plate" tags={["Entree"]} />
32+
</div>
2933
</main>
3034
);
3135
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { GripVertical } from "lucide-react";
2+
3+
export type CalendarRecipeItemProps = {
4+
name: string;
5+
calories?: number;
6+
servingSize?: string;
7+
tags?: string[];
8+
};
9+
10+
const TAG_STYLES: Record<string, string> = {
11+
Combo: "bg-combo-500 text-combo-900",
12+
Sides: "bg-lime text-black",
13+
Fruit: "bg-fruit-900 text-white",
14+
Entree: "bg-entree-900 text-white",
15+
Entrée: "bg-entree-900 text-white",
16+
fallback: "bg-pepper text-white",
17+
};
18+
19+
export default function CalendarRecipeItem({ name, calories, servingSize, tags = [] }: CalendarRecipeItemProps) {
20+
const caloriesText = calories != null ? `${calories} cal` : null;
21+
const servingText = servingSize != null ? `${servingSize}` : null;
22+
const metaText = caloriesText && servingText ? `${caloriesText} / ${servingText}` : caloriesText || servingText;
23+
24+
const primaryTag = tags[0];
25+
const tagStyle = (primaryTag && TAG_STYLES[primaryTag]) ?? TAG_STYLES.fallback;
26+
27+
return (
28+
<div className={`flex items-center gap-3 rounded-xl px-4 py-3 font-montserrat ${tagStyle}`}>
29+
<div className="min-w-0 flex-1">
30+
<p className="truncate text-xl leading-tight font-bold" title={name}>
31+
{name}
32+
</p>
33+
{metaText ? <p className="mt-1 text-lg leading-tight font-medium">{metaText}</p> : null}
34+
</div>
35+
36+
<GripVertical className="h-7 w-7 shrink-0 text-current" aria-hidden="true" />
37+
</div>
38+
);
39+
}

0 commit comments

Comments
 (0)