feat(menu-app): full redesign to Olive & Thyme design spec
Rebuild the public-facing digital menu from the design handoff bundle. Matches high-fidelity spec: Bricolage Grotesque + Hanken Grotesk fonts, cream/green/gold palette, per-category tinted panels, product cards with gradient art, tag icon badges, bottom-sheet product detail, search overlay, cart → checkout bottom-sheet flow posting to real API, floating cart button with bump animation, and restyled order-confirm page. - New: src/components/primitives.jsx (DishArt, Badge, DietChip, TagIcons, Price, DiscountFlag, Stepper, price helpers) - Rewrite: MenuPage.jsx — all screens in one component tree, API-driven, lang toggle (EN/GR) persisted to localStorage, scroll-spy category bar - Rewrite: OrderConfirm.jsx — design-system styling, brand colors - Update: App.jsx — remove /order route (cart flow is now a bottom sheet) - Update: tailwind.config.js — font families, brand tokens, animations - Update: index.html — Google Fonts for Bricolage Grotesque + Hanken Grotesk - Delete: CartPage, ProductModal, ProductCard, CategoryNav, CartButton Cart checkout POSTs to real submitOrder API and redirects to /confirm/:ref for live order status polling. Restaurant info falls back to hardcoded placeholder until backend includes it in the fetchMenu response (see REWORK_REVISIT.md). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,209 @@
|
||||
import {
|
||||
Leaf, Sprout, Wheat, Flame, Star, ChefHat,
|
||||
Minus, Plus,
|
||||
} from 'lucide-react'
|
||||
|
||||
// ── Money helpers ────────────────────────────────────────────────────────────
|
||||
export function eur(n) {
|
||||
return '€' + Number(n).toFixed(2)
|
||||
}
|
||||
|
||||
export function discountedPrice(product) {
|
||||
const base = product.digital_price ?? product.base_price ?? product.price ?? 0
|
||||
const pct = product.digital_discount ?? product.discountPct ?? 0
|
||||
if (!pct) return base
|
||||
return Math.round(base * (1 - pct / 100) * 100) / 100
|
||||
}
|
||||
|
||||
export function basePrice(product) {
|
||||
return product.digital_price ?? product.base_price ?? product.price ?? 0
|
||||
}
|
||||
|
||||
export function hasDiscount(product) {
|
||||
const pct = product.digital_discount ?? product.discountPct ?? 0
|
||||
return pct > 0
|
||||
}
|
||||
|
||||
export function discountPct(product) {
|
||||
return product.digital_discount ?? product.discountPct ?? 0
|
||||
}
|
||||
|
||||
// ── Placeholder gradient art ─────────────────────────────────────────────────
|
||||
export function DishArt({ product, category, size = 'card' }) {
|
||||
const hue = category?.hue ?? 40
|
||||
const GlyphIcon = category?.GlyphIcon ?? null
|
||||
const id = product?.id ?? 'x'
|
||||
let seed = 0
|
||||
for (let i = 0; i < id.length; i++) seed += id.charCodeAt(i)
|
||||
const lift = (seed % 5) - 2
|
||||
const c1 = `hsl(${hue} 34% ${90 + lift}%)`
|
||||
const c2 = `hsl(${hue} 30% ${80 + lift}%)`
|
||||
const glyphColor = `hsl(${hue} 32% 42%)`
|
||||
const firstName = product?.digital_name || product?.name || '?'
|
||||
const letter = typeof firstName === 'object' ? (firstName.en?.[0] ?? '?') : (firstName[0] ?? '?')
|
||||
|
||||
const sizeClass =
|
||||
size === 'hero'
|
||||
? 'self-stretch min-h-[100px] w-[100px]'
|
||||
: size === 'sm'
|
||||
? 'h-16 w-16'
|
||||
: 'h-[92px] w-[92px]'
|
||||
const iconClass = size === 'sm' ? 'h-7 w-7' : 'h-9 w-9'
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`relative flex ${sizeClass} shrink-0 items-center justify-center overflow-hidden rounded-[13px]`}
|
||||
style={{ background: `linear-gradient(135deg, ${c1}, ${c2})` }}
|
||||
>
|
||||
<span
|
||||
className="absolute -right-2 -top-3 font-display text-[56px] leading-none opacity-[0.14] select-none"
|
||||
style={{ color: glyphColor }}
|
||||
>
|
||||
{letter}
|
||||
</span>
|
||||
{GlyphIcon && (
|
||||
<GlyphIcon
|
||||
className={iconClass}
|
||||
style={{ color: glyphColor, opacity: 0.62 }}
|
||||
strokeWidth={1.4}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ── Badge (Popular / Chef's pick) ────────────────────────────────────────────
|
||||
export function Badge({ kind, t }) {
|
||||
if (kind === 'popular') {
|
||||
return (
|
||||
<span className="inline-flex items-center gap-1 rounded-full bg-[#f4ecd8] px-2 py-[3px] text-[10px] font-semibold uppercase tracking-[0.08em] text-[#a9842f] ring-1 ring-inset ring-[#e4d4a8]">
|
||||
<Flame className="h-3 w-3" strokeWidth={2.2} />
|
||||
{t?.popular ?? 'Popular'}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
if (kind === 'chefs') {
|
||||
return (
|
||||
<span className="inline-flex items-center gap-1 rounded-full bg-[#2d3b2d] px-2 py-[3px] text-[10px] font-semibold uppercase tracking-[0.08em] text-[#f0e9d6]">
|
||||
<ChefHat className="h-3 w-3" strokeWidth={2} />
|
||||
{t?.chefs ?? "Chef's pick"}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// ── Dietary chips (with text labels) ────────────────────────────────────────
|
||||
const DIET_STYLE = {
|
||||
vegan: { Icon: Leaf, fg: '#3f7d4e', bg: '#e7f1e7', ring: '#c9e2cb' },
|
||||
vegetarian: { Icon: Sprout, fg: '#5d7a37', bg: '#eef2e0', ring: '#d8e2bd' },
|
||||
'gluten-free': { Icon: Wheat, fg: '#a9842f', bg: '#f5edd8', ring: '#e6d6a6' },
|
||||
spicy: { Icon: Flame, fg: '#c2602f', bg: '#f7e6dc', ring: '#eccab3' },
|
||||
}
|
||||
|
||||
export function DietChip({ tag, t }) {
|
||||
const s = DIET_STYLE[tag]
|
||||
if (!s) return null
|
||||
const { Icon } = s
|
||||
const label = t?.dietary?.[tag] ?? tag
|
||||
return (
|
||||
<span
|
||||
className="inline-flex items-center gap-1 rounded-full px-[7px] py-[2px] text-[10px] font-medium ring-1 ring-inset"
|
||||
style={{ color: s.fg, background: s.bg, borderColor: s.ring }}
|
||||
>
|
||||
<Icon className="h-[11px] w-[11px]" strokeWidth={2} />
|
||||
{label}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
// ── Compact tag icon badges (card title row) ─────────────────────────────────
|
||||
const TAG_BADGE = {
|
||||
vegan: { Icon: Leaf, fg: '#3f7d4e', bg: '#e7f1e7', ring: '#bcdcc0' },
|
||||
vegetarian: { Icon: Sprout, fg: '#5d7a37', bg: '#eef2e0', ring: '#cfe0b0' },
|
||||
'gluten-free': { Icon: Wheat, fg: '#9a7726', bg: '#f6edd6', ring: '#e6d49e' },
|
||||
spicy: { Icon: Flame, fg: '#c2602f', bg: '#f8e6da', ring: '#eec4ac' },
|
||||
}
|
||||
const PRIORITY_BADGE = {
|
||||
popular: { Icon: Star, fg: '#a9842f', bg: '#f6edd6', ring: '#e6d49e' },
|
||||
chefs: { Icon: ChefHat, fg: '#f0e9d6', bg: '#2d3b2d', ring: '#2d3b2d' },
|
||||
}
|
||||
|
||||
export function TagIcons({ product }) {
|
||||
const items = []
|
||||
const badge = product.badge ?? product.digital_badge
|
||||
if (badge && PRIORITY_BADGE[badge]) items.push(PRIORITY_BADGE[badge])
|
||||
const tags = product.tags ?? product.digital_tags ?? []
|
||||
tags.forEach(tag => { if (TAG_BADGE[tag]) items.push(TAG_BADGE[tag]) })
|
||||
const shown = items.slice(0, 3)
|
||||
if (!shown.length) return null
|
||||
return (
|
||||
<div className="flex shrink-0 items-center gap-1 pt-[3px]">
|
||||
{shown.map((s, i) => {
|
||||
const { Icon } = s
|
||||
return (
|
||||
<span
|
||||
key={i}
|
||||
className="flex h-[19px] w-[19px] items-center justify-center rounded-full ring-1 ring-inset"
|
||||
style={{ color: s.fg, background: s.bg, borderColor: s.ring }}
|
||||
>
|
||||
<Icon className="h-[11px] w-[11px]" strokeWidth={2.2} />
|
||||
</span>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ── Price display ─────────────────────────────────────────────────────────────
|
||||
export function Price({ product, large }) {
|
||||
const base = basePrice(product)
|
||||
const now = discountedPrice(product)
|
||||
const discounted = hasDiscount(product)
|
||||
return (
|
||||
<div className="flex items-baseline gap-1.5">
|
||||
{discounted && (
|
||||
<span className="font-display text-[15px] text-[#b3aa97] line-through">{eur(base)}</span>
|
||||
)}
|
||||
<span
|
||||
className={`font-display ${large ? 'text-[22px]' : 'text-[19px]'} font-semibold ${discounted ? 'text-[#c2602f]' : 'text-[#2d3b2d]'}`}
|
||||
>
|
||||
{eur(now)}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ── Discount flag ─────────────────────────────────────────────────────────────
|
||||
export function DiscountFlag({ product, t }) {
|
||||
const pct = discountPct(product)
|
||||
if (!pct) return null
|
||||
return (
|
||||
<span className="inline-flex items-center rounded-md bg-[#c2602f] px-1.5 py-[2px] font-sans text-[10px] font-bold tracking-[0.05em] text-white">
|
||||
−{pct}% {t?.off ?? 'OFF'}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
// ── Quantity stepper ─────────────────────────────────────────────────────────
|
||||
export function Stepper({ qty, onInc, onDec }) {
|
||||
return (
|
||||
<div className="flex items-center gap-3 rounded-full bg-[#f3efe5] p-1 ring-1 ring-inset ring-[#e8e1d1]">
|
||||
<button
|
||||
onClick={onDec}
|
||||
className="flex h-7 w-7 items-center justify-center rounded-full bg-white text-[#2d3b2d] shadow-sm ring-1 ring-[#e8e1d1] transition active:scale-90"
|
||||
>
|
||||
<Minus className="h-3.5 w-3.5" strokeWidth={2.5} />
|
||||
</button>
|
||||
<span className="min-w-[16px] text-center font-display text-[16px] font-semibold tabular-nums text-[#2d3b2d]">
|
||||
{qty}
|
||||
</span>
|
||||
<button
|
||||
onClick={onInc}
|
||||
className="flex h-7 w-7 items-center justify-center rounded-full bg-[#2d3b2d] text-white shadow-sm transition active:scale-90"
|
||||
>
|
||||
<Plus className="h-3.5 w-3.5" strokeWidth={2.5} />
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user