@spunto/brand-kit 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,159 @@
1
+ "use client"
2
+
3
+ import { FONT, hexAlpha } from "../../../theme"
4
+ import { AppWindow, Float, MUTED, Stage, u, useStage, type StageColors } from "../stage"
5
+ import { AppShell, Bubble, Chip, eur, Glyph, num, Painting, Pill, ROOM, t, Thread, WIN, type Lang } from "./parts"
6
+ import { APP, CUPBOARDS, FRIDGE, RECEIPT, THREAD, UI, type StockRow } from "./sample"
7
+
8
+ /* The Stock page, back from the shops: a photo of the receipt goes to the assistant, it reads it, and the pantry
9
+ fills — the milk, the eggs, the lentils and the penne go up, their « à racheter » goes, and the figures on top follow.
10
+
11
+ Drawn from app/src/views/stock.jsx (the four figures, « Dans la cuisine », a row per item with its painting and
12
+ its − qty + ) — what the page itself says it is for: « les courses (photo du ticket) ». */
13
+
14
+ const H = 560
15
+ const STILL = 5
16
+ /* 0 rest · 1 the receipt · 2 it reads · 3 milk and eggs · 4 lentils and penne · 5 the figures follow · 6 the panel closes · 7 rest */
17
+ const LENGTHS = [1200, 1500, 1300, 750, 750, 3200, 500, 900] as const
18
+
19
+ const ROW = 35
20
+ const ALL = [...FRIDGE, ...CUPBOARDS]
21
+ const value = (rows: StockRow[], after: boolean) => rows.reduce((s, r) => s + (after ? r.after : r.qty) * r.price, 0)
22
+
23
+ export function PantryScreen({ lang, colors, night, label }: { lang: Lang; colors: StageColors; night: boolean; label: string }) {
24
+ const { ref, step } = useStage(LENGTHS, STILL)
25
+ // Which rows have taken in the shopping: the fridge's at step 3, the cupboards' at step 4.
26
+ const stocked = (r: StockRow) => r.after !== r.qty && ((step >= 3 && step <= 6 && FRIDGE.includes(r)) || (step >= 4 && step <= 6))
27
+ const done = step >= 5 && step <= 6
28
+ const low = ALL.filter((r) => (r.low || r.out) && !stocked(r))
29
+ const tiles = [
30
+ { label: UI.value, value: eur(Math.round(value(ALL, done)), lang), hint: t(UI.items(ALL.length), lang) },
31
+ { label: UI.rebuy, value: String(low.length), hint: low.length ? low.map((r) => t(r.name, lang)).join(", ") : "—", red: low.length > 0 },
32
+ { label: UI.in30, value: done ? eur(13.5, lang) : eur(0, lang), hint: t(UI.in30Hint, lang) },
33
+ { label: UI.out30, value: eur(2, lang), hint: t(UI.out30Hint, lang) },
34
+ ]
35
+ const TW = (ROOM - 8 * 3) / 4
36
+
37
+ return (
38
+ <Stage stageRef={ref} colors={colors} night={night} height={H} label={label}>
39
+ <AppWindow {...WIN} h={H} address="foyer.spunto.net/app/#/stock">
40
+ <AppShell lang={lang} colors={colors} active={2} title={t(UI.pantry, lang)}>
41
+ {tiles.map((x, i) => (
42
+ <div key={i} style={{ position: "absolute", left: u(i * (TW + 8)), top: 0, width: u(TW), height: u(62), padding: `${u(8)} ${u(10)}`, borderRadius: u(8), background: APP.muted, boxShadow: `0 0 0 1px ${APP.border}` }}>
43
+ <div style={{ fontSize: u(8.4), color: MUTED }}>{t(x.label, lang)}</div>
44
+ <div style={{ marginTop: u(2), fontFamily: FONT.display, fontSize: u(16), color: x.red ? APP.red : undefined, transition: "color 0.3s ease" }}>{x.value}</div>
45
+ <div style={{ fontSize: u(7.8), color: MUTED, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>{x.hint}</div>
46
+ </div>
47
+ ))}
48
+
49
+ <div style={{ position: "absolute", left: 0, top: u(72), width: u(ROOM), bottom: u(-20), padding: `${u(12)} ${u(14)}`, borderRadius: u(10), background: APP.card, boxShadow: `0 0 0 1px ${APP.border}` }}>
50
+ <div style={{ fontFamily: FONT.display, fontSize: u(12) }}>{t(UI.kitchen, lang)}</div>
51
+ <div style={{ marginTop: u(3), maxWidth: u(440), fontSize: u(8.4), color: MUTED }}>{t(UI.kitchenSub, lang)}</div>
52
+ <div style={{ display: "flex", alignItems: "center", gap: u(6), height: u(22), marginTop: u(9), padding: `0 ${u(8)}`, borderRadius: u(5), boxShadow: `inset 0 0 0 1px ${APP.border}`, fontSize: u(9), color: MUTED }}>
53
+ <Glyph id="search" size={10} color={MUTED} />
54
+ {t(UI.search, lang)}
55
+ </div>
56
+ <div style={{ display: "flex", gap: u(5), marginTop: u(8) }}>
57
+ {UI.filters.map((f, i) => (
58
+ <span key={i} style={{ padding: `${u(2.5)} ${u(9)}`, borderRadius: u(20), fontSize: u(8.6), background: i ? "transparent" : APP.accent, color: i ? MUTED : APP.accentInk, boxShadow: `inset 0 0 0 1px ${i ? APP.border : hexAlpha(colors.tone, 0.35)}` }}>
59
+ {t(f, lang)}
60
+ </span>
61
+ ))}
62
+ </div>
63
+ <Shelf lang={lang} title={`${t(UI.fridge, lang)} · ${FRIDGE.length}`} rows={FRIDGE} stocked={stocked} />
64
+ <Shelf lang={lang} title={`${t(UI.cupboards, lang)} · ${CUPBOARDS.length}`} rows={CUPBOARDS} stocked={stocked} />
65
+ </div>
66
+ </AppShell>
67
+ </AppWindow>
68
+
69
+ <Float x={36} y={150} w={150} depth={150} show={step >= 1 && step <= 5} style={{ borderRadius: 0, boxShadow: "none", overflow: "visible" }}>
70
+ <Receipt />
71
+ </Float>
72
+
73
+ <Float x={30} y={392} w={214} depth={90} show={step >= 1 && step <= 5}>
74
+ <Thread lang={lang} colors={colors}>
75
+ <Bubble from="you" tone={colors.tone}>
76
+ <span style={{ display: "flex", alignItems: "center", gap: u(5) }}>
77
+ <Glyph id="camera" size={10} color="#ffffff" />
78
+ {t(THREAD.receipt, lang)}
79
+ </span>
80
+ </Bubble>
81
+ <div style={{ display: step >= 2 ? "flex" : "none" }}>
82
+ <Chip icon="camera" done={step >= 3}>
83
+ {t(THREAD.readReceipt, lang)}
84
+ </Chip>
85
+ </div>
86
+ <div style={{ display: done ? "flex" : "none", justifyContent: "center" }}>
87
+ <Pill kind="done" size={8.8}>
88
+ {t(THREAD.stocked, lang)}
89
+ </Pill>
90
+ </div>
91
+ </Thread>
92
+ </Float>
93
+ </Stage>
94
+ )
95
+ }
96
+
97
+ function Shelf({ lang, title, rows, stocked }: { lang: Lang; title: string; rows: StockRow[]; stocked: (r: StockRow) => boolean }) {
98
+ return (
99
+ <div style={{ marginTop: u(10) }}>
100
+ <div style={{ padding: `0 ${u(4)} ${u(4)}`, borderBottom: `1px solid ${APP.border}`, fontSize: u(8.2), letterSpacing: "0.06em", textTransform: "uppercase", color: MUTED }}>{title}</div>
101
+ {rows.map((r, i) => {
102
+ const on = stocked(r)
103
+ const qty = on ? r.after : r.qty
104
+ return (
105
+ <div key={i} style={{ display: "flex", alignItems: "center", gap: u(9), height: u(ROW), padding: `0 ${u(4)}` }}>
106
+ <Painting src={r.painting} w={28} h={28} radius={6} />
107
+ <div style={{ minWidth: 0, flex: 1 }}>
108
+ <div style={{ fontSize: u(9.6), fontWeight: 500 }}>{t(r.name, lang)}</div>
109
+ <div style={{ display: "flex", alignItems: "center", gap: u(5), fontSize: u(8), color: MUTED }}>
110
+ {t(r.unit, lang)}
111
+ {(r.low || r.out) && !on && <Pill kind="low" size={7.4}>{t(UI.rebuyBadge, lang)}</Pill>}
112
+ </div>
113
+ </div>
114
+ <span style={{ width: u(34), textAlign: "right", fontSize: u(9), fontWeight: 600, color: APP.green, opacity: on ? 1 : 0, transform: on ? "none" : `translateY(${u(4)})`, transition: "opacity 0.3s ease, transform 0.4s ease" }}>
115
+ +{num(r.after - r.qty, lang)}
116
+ </span>
117
+ <span style={{ display: "flex", alignItems: "center", gap: u(8), fontSize: u(9.6) }}>
118
+ <Glyph id="minus" size={10} color={MUTED} />
119
+ <span style={{ width: u(26), textAlign: "center", fontWeight: 600, fontVariantNumeric: "tabular-nums" }}>{num(qty, lang)}</span>
120
+ <Glyph id="plus" size={10} color={MUTED} />
121
+ </span>
122
+ <span style={{ width: u(44), textAlign: "right", fontSize: u(8.8), color: MUTED, fontVariantNumeric: "tabular-nums" }}>{eur(Math.round(qty * r.price * 100) / 100, lang)}</span>
123
+ </div>
124
+ )
125
+ })}
126
+ </div>
127
+ )
128
+ }
129
+
130
+ /** The till receipt, as it was photographed: a strip of thermal paper, its torn edge. */
131
+ function Receipt() {
132
+ return (
133
+ <div style={{ transform: "rotate(-3deg)", filter: `drop-shadow(0 ${u(14)} ${u(16)} rgba(0,0,0,0.4))` }}>
134
+ <div
135
+ style={{
136
+ padding: `${u(10)} ${u(10)} ${u(16)}`,
137
+ background: "#ffffff",
138
+ color: "#57534e",
139
+ fontFamily: FONT.mono,
140
+ fontSize: u(7.6),
141
+ lineHeight: 1.55,
142
+ clipPath: "polygon(0 0, 100% 0, 100% calc(100% - 6px), 92% 100%, 84% calc(100% - 6px), 76% 100%, 68% calc(100% - 6px), 60% 100%, 52% calc(100% - 6px), 44% 100%, 36% calc(100% - 6px), 28% 100%, 20% calc(100% - 6px), 12% 100%, 4% calc(100% - 6px), 0 100%)",
143
+ }}
144
+ >
145
+ <div style={{ marginBottom: u(6), textAlign: "center", fontWeight: 700, letterSpacing: "0.12em" }}>{RECEIPT.shop}</div>
146
+ {RECEIPT.lines.map(([a, b]) => (
147
+ <div key={a} style={{ display: "flex", justifyContent: "space-between", gap: u(6) }}>
148
+ <span style={{ whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>{a}</span>
149
+ <span>{b}</span>
150
+ </div>
151
+ ))}
152
+ <div style={{ display: "flex", justifyContent: "space-between", marginTop: u(6), paddingTop: u(3), borderTop: "1px dashed #a8a29e", fontWeight: 700 }}>
153
+ <span>TOTAL</span>
154
+ <span>{RECEIPT.total}</span>
155
+ </div>
156
+ </div>
157
+ </div>
158
+ )
159
+ }
@@ -0,0 +1,226 @@
1
+ "use client"
2
+
3
+ import type { CSSProperties, ReactNode } from "react"
4
+ import type { Words } from "../../../facts"
5
+ import { FONT, hexAlpha } from "../../../theme"
6
+ import { INK, MUTED, u, type StageColors } from "../stage"
7
+ import { APP, UI } from "./sample"
8
+
9
+ /* What the Foyer screens share: the app's shell (sidebar, page head), its paintings, its badges and icons.
10
+ Positions are the window's design pixels. */
11
+
12
+ export type Lang = "en" | "fr"
13
+ export const t = (x: Words, lang: Lang) => x[lang]
14
+
15
+ /** The app's window on the 920-wide board. */
16
+ export const WIN = { x: 24, y: 30, w: 872 }
17
+ export const SIDEBAR = 150
18
+ export const PAD = 18
19
+ export const ROOM = WIN.w - SIDEBAR - PAD * 2
20
+
21
+ /** The app's icons (lucide, as the app draws them: 24 × 24 strokes). */
22
+ const ICON = {
23
+ utensils: "M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2M7 2v20M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3zM21 15v7",
24
+ book: "M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2zM22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",
25
+ fridge: "M5 6a4 4 0 0 1 4-4h6a4 4 0 0 1 4 4v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2zM5 10h14M15 7v6",
26
+ list: "M3 17l2 2l4-4M3 7l2 2l4-4M13 6h8M13 12h8M13 18h8",
27
+ bot: "M12 8V4H8M4 8h16v12H4zM2 14h2M20 14h2M15 13v2M9 13v2",
28
+ house: "M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8M3 10a2 2 0 0 1 .7-1.5l7-6a2 2 0 0 1 2.6 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",
29
+ sparkles: "M9.9 15.5A2 2 0 0 0 8.5 14.1L2.4 12.5a.5.5 0 0 1 0-1l6.1-1.6A2 2 0 0 0 9.9 8.5l1.6-6.1a.5.5 0 0 1 1 0l1.6 6.1a2 2 0 0 0 1.4 1.4l6.1 1.6a.5.5 0 0 1 0 1l-6.1 1.6a2 2 0 0 0-1.4 1.4l-1.6 6.1a.5.5 0 0 1-1 0z",
30
+ camera: "M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3zM12 10a3 3 0 1 0 0 6a3 3 0 0 0 0-6z",
31
+ leaf: "M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.5 19 2c1 2 2 4.2 2 8c0 5.5-4.8 10-10 10zM2 21c0-3 1.9-5.4 5.1-6",
32
+ clock: "M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18zM12 7v5l3 2",
33
+ check: "M5 12.5l4.5 4.5L19 7.5",
34
+ chef: "M17 21a1 1 0 0 0 1-1v-5.4a1 1 0 0 1 .6-.9A4 4 0 0 0 17.1 6a5 5 0 0 0-10.2 0A4 4 0 0 0 5.4 13.7a1 1 0 0 1 .6.9V20a1 1 0 0 0 1 1zM6 17h12",
35
+ people: "M9 5a3.5 3.5 0 1 0 0 7a3.5 3.5 0 0 0 0-7zM3 20a6 6 0 0 1 12 0M16 5.4a3.5 3.5 0 0 1 0 6.3M18 14.6a6 6 0 0 1 3 5.4",
36
+ sun: "M12 8a4 4 0 1 0 0 8a4 4 0 0 0 0-8zM12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4",
37
+ moon: "M12 3a6 6 0 0 0 9 9a9 9 0 1 1-9-9z",
38
+ search: "M11 4a7 7 0 1 0 0 14a7 7 0 0 0 0-14zM20 20l-3.5-3.5",
39
+ plus: "M12 5v14M5 12h14",
40
+ minus: "M5 12h14",
41
+ chevron: "M6 9l6 6l6-6",
42
+ mic: "M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3zM19 10v2a7 7 0 0 1-14 0v-2M12 19v3",
43
+ paperclip: "M13.2 6.8l-6.4 6.4a2.5 2.5 0 0 0 3.5 3.5l7.1-7.1a4.5 4.5 0 0 0-6.4-6.4l-7.1 7.1a6.5 6.5 0 0 0 9.2 9.2l6.4-6.4",
44
+ } as const
45
+
46
+ export type FoyerIcon = keyof typeof ICON
47
+
48
+ export function Glyph({ id, size = 12, color = "currentColor", width = 1.8, style }: { id: FoyerIcon; size?: number; color?: string; width?: number; style?: CSSProperties }) {
49
+ return (
50
+ <svg viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth={width} strokeLinecap="round" strokeLinejoin="round" style={{ display: "block", flexShrink: 0, width: u(size), height: u(size), ...style }}>
51
+ <path d={ICON[id]} />
52
+ </svg>
53
+ )
54
+ }
55
+
56
+ /** One of the app's paintings, on its cream, cropped like the app crops it (object-fit: cover). */
57
+ export function Painting({ src, w, h, radius = 8, style, children }: { src: string; w: number | string; h: number | string; radius?: number; style?: CSSProperties; children?: ReactNode }) {
58
+ return (
59
+ <span style={{ position: "relative", display: "block", flexShrink: 0, width: typeof w === "number" ? u(w) : w, height: typeof h === "number" ? u(h) : h, borderRadius: u(radius), overflow: "hidden", background: APP.illus, ...style }}>
60
+ <img src={src} alt="" loading="lazy" decoding="async" draggable={false} style={{ display: "block", width: "100%", height: "100%", objectFit: "cover" }} />
61
+ {children}
62
+ </span>
63
+ )
64
+ }
65
+
66
+ /** Foyer's mark: Spunto's `mark` variant on its tile, in the product's colours (app/src/components/logo.jsx:
67
+ `SpuntoLogo tone="product" variant="mark"` — the shapes of design-system/src/brand/logo.ts). */
68
+ export function FoyerMark({ size = 16, colors }: { size?: number; colors: StageColors }) {
69
+ return (
70
+ <svg viewBox="0 0 128 128" style={{ display: "block", flexShrink: 0, width: u(size), height: u(size) }}>
71
+ <rect width="128" height="128" rx="14" fill={colors.signal} />
72
+ <path d="M18 18h72v14H32v58H18zM110 110H38V96h58V38h14z" fill={colors.field} />
73
+ <circle cx="64" cy="64" r="18" fill={colors.field} />
74
+ </svg>
75
+ )
76
+ }
77
+
78
+ /** A rounded label: « De saison » (green, filled), « Officielle » / « À tester » (outlined), « à racheter » (amber). */
79
+ export function Pill({ kind, children, size = 8.4 }: { kind: "season" | "official" | "toTry" | "low" | "today" | "done"; children: ReactNode; size?: number }) {
80
+ const look: Record<typeof kind, CSSProperties> = {
81
+ season: { background: APP.green, color: "#ffffff" },
82
+ official: { background: "#ffffff", color: APP.green, boxShadow: `inset 0 0 0 1px ${hexAlpha(APP.green, 0.5)}` },
83
+ toTry: { background: "#ffffff", color: MUTED, boxShadow: `inset 0 0 0 1px ${APP.border}` },
84
+ low: { background: hexAlpha(APP.amber, 0.14), color: APP.amber },
85
+ today: { background: APP.accent, color: APP.accentInk },
86
+ done: { background: hexAlpha(APP.green, 0.13), color: APP.green },
87
+ }
88
+ return (
89
+ <span style={{ display: "inline-flex", alignItems: "center", gap: u(3), padding: `${u(1.5)} ${u(6)}`, borderRadius: u(20), fontSize: u(size), fontWeight: 550, whiteSpace: "nowrap", lineHeight: 1.3, ...look[kind] }}>
90
+ {kind === "season" && <Glyph id="leaf" size={size} color="#ffffff" width={2.2} />}
91
+ {kind === "done" && <Glyph id="check" size={size} color={APP.green} width={2.4} />}
92
+ {children}
93
+ </span>
94
+ )
95
+ }
96
+
97
+ /** A button as the app draws it: filled in the product's colour, or outlined. */
98
+ export function Btn({ icon, children, tone, outline, pressed, size = 10 }: { icon?: FoyerIcon; children: ReactNode; tone: string; outline?: boolean; pressed?: boolean; size?: number }) {
99
+ return (
100
+ <span
101
+ style={{
102
+ display: "inline-flex",
103
+ alignItems: "center",
104
+ gap: u(5),
105
+ height: u(size * 2.5),
106
+ padding: `0 ${u(size)}`,
107
+ borderRadius: u(5),
108
+ fontSize: u(size),
109
+ fontWeight: 550,
110
+ whiteSpace: "nowrap",
111
+ background: outline ? "#ffffff" : tone,
112
+ color: outline ? INK : "#ffffff",
113
+ boxShadow: outline ? `inset 0 0 0 1px ${APP.border}` : "none",
114
+ transform: pressed ? "scale(0.95)" : "none",
115
+ transition: "transform 0.15s ease",
116
+ }}
117
+ >
118
+ {icon && <Glyph id={icon} size={size * 1.15} color={outline ? INK : "#ffffff"} />}
119
+ {children}
120
+ </span>
121
+ )
122
+ }
123
+
124
+ /** The four people at the table: their initials, as the app draws faces without a photo. */
125
+ export function Faces({ size = 14 }: { size?: number }) {
126
+ const people: [string, string][] = [["C", "#f6c9c4"], ["S", "#c9dbef"], ["L", "#d4e5cf"], ["J", "#f5dcb3"]]
127
+ return (
128
+ <span style={{ display: "inline-flex" }}>
129
+ {people.map(([l, bg], i) => (
130
+ <span key={l} style={{ display: "grid", placeItems: "center", width: u(size), height: u(size), marginLeft: i ? u(-size * 0.3) : 0, borderRadius: "50%", background: bg, boxShadow: `0 0 0 ${u(1.5)} #ffffff`, fontSize: u(size * 0.5), fontWeight: 600, color: "#7a3b2e" }}>
131
+ {l}
132
+ </span>
133
+ ))}
134
+ </span>
135
+ )
136
+ }
137
+
138
+ const NAV_ICON: FoyerIcon[] = ["utensils", "book", "fridge", "list", "bot", "house"]
139
+
140
+ /** The sidebar and the head of the page. `active`: the page's index in the nav. */
141
+ export function AppShell({ lang, colors, active, title, children }: { lang: Lang; colors: StageColors; active: number; title: string; children: ReactNode }) {
142
+ return (
143
+ <div style={{ position: "absolute", inset: 0, background: APP.bg }}>
144
+ <div style={{ position: "absolute", left: 0, top: 0, bottom: 0, width: u(SIDEBAR), background: APP.sidebar, borderRight: `1px solid ${APP.border}` }}>
145
+ <div style={{ display: "flex", alignItems: "center", gap: u(7), margin: `${u(14)} ${u(12)} 0`, fontFamily: FONT.display, fontSize: u(13), whiteSpace: "nowrap" }}>
146
+ <FoyerMark size={18} colors={colors} />
147
+ Foyer
148
+ </div>
149
+ <div style={{ display: "flex", alignItems: "center", gap: u(6), height: u(26), margin: `${u(13)} ${u(9)} 0`, padding: `0 ${u(8)}`, border: `1px solid ${APP.border}`, borderRadius: u(5), background: APP.card, fontSize: u(10.4) }}>
150
+ <Glyph id="house" size={11} color={MUTED} />
151
+ <span style={{ flex: 1, textAlign: "center" }}>{UI.household}</span>
152
+ <Glyph id="chevron" size={10} color={MUTED} />
153
+ </div>
154
+ <div style={{ margin: `${u(12)} ${u(9)} 0`, display: "flex", flexDirection: "column", gap: u(2) }}>
155
+ {UI.nav.map((label, i) => (
156
+ <div key={i} style={{ display: "flex", alignItems: "center", gap: u(7), height: u(23), padding: `0 ${u(7)}`, borderRadius: u(5), background: i === active ? APP.accent : "transparent", fontSize: u(10.4), color: i === active ? APP.accentInk : MUTED, whiteSpace: "nowrap" }}>
157
+ <Glyph id={NAV_ICON[i]} size={11} color={i === active ? colors.tone : MUTED} />
158
+ {t(label, lang)}
159
+ </div>
160
+ ))}
161
+ </div>
162
+ </div>
163
+ <div style={{ position: "absolute", left: u(SIDEBAR + PAD), right: u(PAD), top: u(12), display: "flex", alignItems: "center" }}>
164
+ <span style={{ fontFamily: FONT.display, fontSize: u(19), letterSpacing: "-0.01em" }}>{title}</span>
165
+ <span style={{ marginLeft: "auto" }}>
166
+ <Btn icon="bot" tone={colors.tone} size={9}>
167
+ {t(UI.assistant, lang)}
168
+ </Btn>
169
+ </span>
170
+ </div>
171
+ <div style={{ position: "absolute", left: u(SIDEBAR + PAD), top: u(50), width: u(ROOM), bottom: 0 }}>{children}</div>
172
+ </div>
173
+ )
174
+ }
175
+
176
+ /** A card of the assistant's thread, floating over the page: the panel the « Assistant » button opens. */
177
+ export function Thread({ lang, colors, children }: { lang: Lang; colors: StageColors; children: ReactNode }) {
178
+ return (
179
+ <div style={{ background: APP.card }}>
180
+ <div style={{ display: "flex", alignItems: "center", gap: u(6), padding: `${u(8)} ${u(11)}`, borderBottom: `1px solid ${APP.border}`, fontSize: u(10), fontWeight: 600 }}>
181
+ <Glyph id="bot" size={12} color={colors.tone} />
182
+ {t(UI.assistant, lang)}
183
+ <span style={{ marginLeft: "auto", fontWeight: 450, color: MUTED, fontSize: u(9) }}>{t(UI.todayTab, lang)}</span>
184
+ </div>
185
+ <div style={{ display: "flex", flexDirection: "column", gap: u(7), padding: u(10), fontSize: u(10), lineHeight: 1.4 }}>{children}</div>
186
+ </div>
187
+ )
188
+ }
189
+
190
+ /** A line of the thread: what someone at home says (right, in the product's colour), or the assistant (left). */
191
+ export function Bubble({ from, tone, show = true, children }: { from: "you" | "agent"; tone: string; show?: boolean; children: ReactNode }) {
192
+ if (!show) return null
193
+ return (
194
+ <div
195
+ style={{
196
+ alignSelf: from === "you" ? "flex-end" : "flex-start",
197
+ maxWidth: "88%",
198
+ padding: `${u(6)} ${u(9)}`,
199
+ borderRadius: from === "you" ? `${u(11)} ${u(11)} ${u(3)} ${u(11)}` : `${u(11)} ${u(11)} ${u(11)} ${u(3)}`,
200
+ background: from === "you" ? tone : APP.muted,
201
+ color: from === "you" ? "#ffffff" : INK,
202
+ }}
203
+ >
204
+ {children}
205
+ </div>
206
+ )
207
+ }
208
+
209
+ /** What the assistant is doing: « Lit le stock », pulsing, then ticked. */
210
+ export function Chip({ icon, done, show = true, children }: { icon: FoyerIcon; done: boolean; show?: boolean; children: ReactNode }) {
211
+ if (!show) return null
212
+ return (
213
+ <span style={{ display: "inline-flex", alignItems: "center", gap: u(4), padding: `${u(2)} ${u(7)}`, borderRadius: u(20), fontSize: u(8.8), color: done ? APP.green : MUTED, boxShadow: `inset 0 0 0 1px ${done ? hexAlpha(APP.green, 0.4) : APP.border}`, transition: "color 0.3s ease" }}>
214
+ <Glyph id={done ? "check" : icon} size={9} color={done ? APP.green : MUTED} width={2.2} />
215
+ {children}
216
+ </span>
217
+ )
218
+ }
219
+
220
+ /** French numbers in French, English ones in English: 0,5 / 0.5. */
221
+ export const num = (n: number, lang: Lang) => n.toLocaleString(lang === "fr" ? "fr-FR" : "en-GB", { maximumFractionDigits: 2 })
222
+ /** An amount: whole euros bare, cents always two digits (13,50 €). */
223
+ export const eur = (n: number, lang: Lang) => {
224
+ const v = n.toLocaleString(lang === "fr" ? "fr-FR" : "en-GB", Number.isInteger(n) ? { maximumFractionDigits: 0 } : { minimumFractionDigits: 2, maximumFractionDigits: 2 })
225
+ return lang === "fr" ? `${v} €` : `€${v}`
226
+ }
@@ -0,0 +1,256 @@
1
+ "use client"
2
+
3
+ import type { ReactNode } from "react"
4
+ import { FONT, hexAlpha } from "../../../theme"
5
+ import { INK, MUTED, Stage, u, useStage, type StageColors } from "../stage"
6
+ import { Btn, Bubble, Chip, FoyerMark, Glyph, Painting, Pill, t, type FoyerIcon, type Lang } from "./parts"
7
+ import { APP, PROPOSAL, THREAD, TODAY, TONIGHT, UI, WEEK, painting } from "./sample"
8
+
9
+ /* The phone, for a hero's column: the Menus page as the app draws it on a phone (« Ce soir » on top, the days under it,
10
+ the round Assistant button in the bottom bar). Nothing is planned tonight; the button is pressed, the assistant's
11
+ sheet rises, it reads the pantry and the cookbook, proposes, is told yes — the sheet goes down on a planned
12
+ evening, tonight's dish painted on top.
13
+
14
+ Drawn from the app at phone width (app/src/views/menus.jsx, the bottom bar of components/shell — five tabs and the
15
+ Assistant in the middle) and the assistant's panel (components/panel.jsx). Its own board: 400 wide. */
16
+
17
+ const BOARD = 400
18
+ const H = 640
19
+ const STILL = 7
20
+ /* 0 rest · 1 the button · 2 the sheet, the question · 3 it reads · 4 its proposal · 5 « oui » · 6 the sheet goes down · 7 planned · 8 rest */
21
+ const LENGTHS = [1400, 600, 1600, 1300, 2600, 900, 700, 3600, 600] as const
22
+
23
+ const PHONE = { x: 52, y: 18, w: 296, h: 604 }
24
+
25
+ export function PhoneScreen({ lang, colors, night, label }: { lang: Lang; colors: StageColors; night: boolean; label: string }) {
26
+ const { ref, step } = useStage(LENGTHS, STILL)
27
+ const sheet = step >= 2 && step <= 5
28
+ const planned = step >= 6 && step <= 8
29
+ const days = WEEK.slice(TODAY)
30
+
31
+ return (
32
+ <Stage stageRef={ref} colors={colors} night={night} height={H} label={label} board={BOARD} bare>
33
+ <div
34
+ style={{
35
+ position: "absolute",
36
+ left: u(PHONE.x),
37
+ top: u(PHONE.y),
38
+ width: u(PHONE.w),
39
+ height: u(PHONE.h),
40
+ padding: u(10),
41
+ borderRadius: u(44),
42
+ background: "#141010",
43
+ boxShadow: `0 ${u(30)} ${u(70)} ${u(-18)} rgba(0,0,0,0.6), inset 0 0 0 ${u(1.5)} rgba(255,255,255,0.14)`,
44
+ transform: "translateY(calc((0.5 - var(--p)) * 40px))",
45
+ }}
46
+ >
47
+ <div style={{ position: "relative", width: "100%", height: "100%", borderRadius: u(35), overflow: "hidden", background: APP.bg, color: INK }}>
48
+ {/* the app's top bar */}
49
+ <div style={{ display: "flex", alignItems: "center", gap: u(7), height: u(46), padding: `${u(10)} ${u(14)} 0`, borderBottom: `1px solid ${APP.border}` }}>
50
+ <FoyerMark size={20} colors={colors} />
51
+ <span style={{ fontFamily: FONT.display, fontSize: u(14) }}>Foyer</span>
52
+ <span style={{ marginLeft: "auto", display: "grid", placeItems: "center", width: u(22), height: u(22), borderRadius: u(5), background: "#f6c9c4", color: "#b42318", fontSize: u(9), fontWeight: 600 }}>C</span>
53
+ </div>
54
+
55
+ <div style={{ padding: `${u(10)} ${u(10)} 0` }}>
56
+ <div style={{ display: "flex", alignItems: "center", marginBottom: u(9) }}>
57
+ <span style={{ fontFamily: FONT.display, fontSize: u(19) }}>{t(UI.nav[0], lang)}</span>
58
+ <span style={{ marginLeft: "auto", display: "flex", alignItems: "center", gap: u(5), height: u(22), padding: `0 ${u(8)}`, borderRadius: u(5), background: APP.card, boxShadow: `inset 0 0 0 1px ${APP.border}`, fontSize: u(9) }}>
59
+ <Glyph id="house" size={10} color={MUTED} />
60
+ {UI.household}
61
+ <Glyph id="chevron" size={9} color={MUTED} />
62
+ </span>
63
+ </div>
64
+
65
+ {/* « Ce soir » — empty, then tonight's dish */}
66
+ <div style={{ position: "relative", height: u(236), borderRadius: u(12), overflow: "hidden", background: APP.card, boxShadow: `0 0 0 1px ${APP.border}` }}>
67
+ <Layer on={!planned}>
68
+ <Painting src={painting("scenes/cloche")} w="100%" h={124} radius={0} />
69
+ <div style={{ padding: `${u(10)} ${u(12)}` }}>
70
+ <Kicker tone={colors.tone}>{t(UI.tonight, lang)}</Kicker>
71
+ <div style={{ marginTop: u(3), fontFamily: FONT.display, fontSize: u(15) }}>{t(UI.nothingTonight, lang)}</div>
72
+ <div style={{ marginTop: u(3), fontSize: u(8.6), color: MUTED, lineHeight: 1.4 }}>{t(UI.nothingTonightSub, lang)}</div>
73
+ <div style={{ display: "flex", gap: u(5), marginTop: u(8) }}>
74
+ <Btn icon="sparkles" tone={colors.tone} size={8.4}>
75
+ {t(UI.fillWeek, lang)}
76
+ </Btn>
77
+ </div>
78
+ </div>
79
+ </Layer>
80
+ <Layer on={planned}>
81
+ <Painting src={TONIGHT.painting} w="100%" h={124} radius={0}>
82
+ <span style={{ position: "absolute", top: u(7), left: u(7) }}>
83
+ <Pill kind="season" size={7.6}>
84
+ {t(UI.inSeason, lang)}
85
+ </Pill>
86
+ </span>
87
+ </Painting>
88
+ <div style={{ padding: `${u(10)} ${u(12)}` }}>
89
+ <Kicker tone={colors.tone}>
90
+ {t(UI.tonight, lang)} · {t(UI.tonightDate, lang)}
91
+ </Kicker>
92
+ <div style={{ marginTop: u(3), fontFamily: FONT.display, fontSize: u(17) }}>{t(TONIGHT.title, lang)}</div>
93
+ <div style={{ marginTop: u(3), fontSize: u(8.6), color: MUTED }}>
94
+ {TONIGHT.time} · {t(UI.serves, lang)}
95
+ </div>
96
+ <div style={{ display: "flex", gap: u(5), marginTop: u(8) }}>
97
+ <Btn icon="chef" tone={colors.tone} size={8.4}>
98
+ {t(UI.cook, lang)}
99
+ </Btn>
100
+ <Btn icon="book" tone={colors.tone} size={8.4} outline>
101
+ {t(UI.seeRecipe, lang)}
102
+ </Btn>
103
+ </div>
104
+ </div>
105
+ </Layer>
106
+ </div>
107
+
108
+ {/* the days to come */}
109
+ <div style={{ display: "flex", flexDirection: "column", gap: u(7), marginTop: u(10) }}>
110
+ {days.map((d, i) => (
111
+ <div key={i} style={{ display: "flex", alignItems: "center", gap: u(9), height: u(50), padding: `0 ${u(9)}`, borderRadius: u(10), background: APP.card, boxShadow: i === 0 ? `0 0 0 ${u(1.5)} ${colors.tone}` : `0 0 0 1px ${APP.border}` }}>
112
+ <div style={{ width: u(62), flexShrink: 0 }}>
113
+ <div style={{ fontFamily: FONT.display, fontSize: u(9.6), color: i === 0 ? colors.tone : INK }}>{t(d.day, lang)}</div>
114
+ <div style={{ display: "flex", alignItems: "center", gap: u(3), marginTop: u(2), fontSize: u(7.4), color: MUTED, textTransform: "uppercase", letterSpacing: "0.04em" }}>
115
+ <Glyph id="moon" size={7.4} color={MUTED} />
116
+ {t(UI.dinner, lang)}
117
+ </div>
118
+ </div>
119
+ <div style={{ position: "relative", flex: 1, height: u(36) }}>
120
+ <Layer on={!planned}>
121
+ <div style={{ height: "100%", display: "flex", alignItems: "center", justifyContent: "center", gap: u(4), border: `1px dashed ${APP.border}`, borderRadius: u(8), fontSize: u(8.4), color: MUTED }}>
122
+ <Glyph id="plus" size={8.4} color={MUTED} />
123
+ {t(UI.nothingPlanned, lang)}
124
+ </div>
125
+ </Layer>
126
+ <Layer on={planned} delay={0.15 + i * 0.18}>
127
+ <div style={{ display: "flex", alignItems: "center", gap: u(7), height: "100%" }}>
128
+ <Painting src={d.meals[0].painting} w={36} h={36} radius={7} />
129
+ <span style={{ minWidth: 0 }}>
130
+ <span style={{ display: "block", fontSize: u(9.4), fontWeight: 500 }}>{t(d.meals[0].title, lang)}</span>
131
+ <span style={{ display: "flex", alignItems: "center", gap: u(3), fontSize: u(7.6), color: colors.tone }}>
132
+ <Glyph id="book" size={7.6} color={colors.tone} />
133
+ {t(UI.recipe, lang)}
134
+ <span style={{ color: MUTED }}>{d.meals[0].time}</span>
135
+ </span>
136
+ </span>
137
+ </div>
138
+ </Layer>
139
+ </div>
140
+ </div>
141
+ ))}
142
+ </div>
143
+ </div>
144
+
145
+ {/* the assistant's sheet */}
146
+ <div
147
+ style={{
148
+ position: "absolute",
149
+ left: 0,
150
+ right: 0,
151
+ bottom: 0,
152
+ height: "76%",
153
+ zIndex: 3,
154
+ borderRadius: `${u(18)} ${u(18)} 0 0`,
155
+ background: APP.card,
156
+ boxShadow: "0 -12px 40px rgba(0,0,0,0.25)",
157
+ transform: sheet ? "none" : "translateY(104%)",
158
+ transition: "transform 0.55s cubic-bezier(0.3, 0.7, 0.2, 1)",
159
+ display: "flex",
160
+ flexDirection: "column",
161
+ }}
162
+ >
163
+ <div style={{ alignSelf: "center", width: u(34), height: u(4), marginTop: u(7), borderRadius: u(2), background: APP.border }} />
164
+ <div style={{ display: "flex", alignItems: "center", gap: u(6), padding: `${u(7)} ${u(14)}`, borderBottom: `1px solid ${APP.border}`, fontSize: u(10.4), fontWeight: 600 }}>
165
+ <Glyph id="bot" size={13} color={colors.tone} />
166
+ {t(UI.assistant, lang)}
167
+ <span style={{ marginLeft: "auto", fontWeight: 450, fontSize: u(9), color: MUTED }}>{t(UI.todayTab, lang)}</span>
168
+ </div>
169
+ <div style={{ flex: 1, display: "flex", flexDirection: "column", justifyContent: "flex-end", gap: u(7), padding: `${u(10)} ${u(12)}`, fontSize: u(10), lineHeight: 1.4, overflow: "hidden" }}>
170
+ <Bubble from="you" tone={colors.tone}>
171
+ {t(THREAD.ask, lang)}
172
+ </Bubble>
173
+ <div style={{ display: step >= 3 ? "flex" : "none", gap: u(4) }}>
174
+ <Chip icon="fridge" done={step >= 4}>
175
+ {t(THREAD.readStock, lang)}
176
+ </Chip>
177
+ <Chip icon="book" done={step >= 4}>
178
+ {t(THREAD.readBook, lang)}
179
+ </Chip>
180
+ </div>
181
+ <Bubble from="agent" tone={colors.tone} show={step >= 4}>
182
+ {t(THREAD.proposal, lang)}
183
+ <div style={{ display: "flex", flexDirection: "column", gap: u(5), margin: `${u(6)} 0` }}>
184
+ {PROPOSAL.map((p, i) => (
185
+ <div key={i} style={{ display: "flex", alignItems: "center", gap: u(6) }}>
186
+ <Painting src={p.meal.painting} w={28} h={28} radius={6} />
187
+ <span style={{ minWidth: 0 }}>
188
+ <span style={{ display: "block", fontWeight: 600, fontSize: u(9.4) }}>
189
+ {t(p.day, lang)} · {t(p.meal.title, lang)}
190
+ </span>
191
+ <span style={{ display: "block", fontSize: u(8.2), color: MUTED }}>{t(p.note, lang)}</span>
192
+ </span>
193
+ </div>
194
+ ))}
195
+ </div>
196
+ {t(THREAD.confirm, lang)}
197
+ </Bubble>
198
+ <Bubble from="you" tone={colors.tone} show={step >= 5}>
199
+ {t(THREAD.yes, lang)}
200
+ </Bubble>
201
+ </div>
202
+ <div style={{ display: "flex", alignItems: "center", gap: u(6), margin: `0 ${u(12)} ${u(64)}`, height: u(28), padding: `0 ${u(10)}`, borderRadius: u(20), boxShadow: `inset 0 0 0 1px ${APP.border}`, fontSize: u(8.8), color: MUTED }}>
203
+ <Glyph id="paperclip" size={10} color={MUTED} />
204
+ {t(UI.placeholder, lang)}
205
+ </div>
206
+ </div>
207
+
208
+ {/* the bottom bar: five tabs, the Assistant in the middle */}
209
+ <div style={{ position: "absolute", left: 0, right: 0, bottom: 0, zIndex: 4, height: u(54), display: "flex", alignItems: "flex-end", paddingBottom: u(8), background: APP.card, borderTop: `1px solid ${APP.border}` }}>
210
+ {([[0, "utensils"], [1, "book"], [4, "bot"], [2, "fridge"], [5, "house"]] as [number, FoyerIcon][]).map(([n, icon], i) =>
211
+ i === 2 ? (
212
+ <div key={i} style={{ flex: 1, display: "flex", flexDirection: "column", alignItems: "center", gap: u(3) }}>
213
+ <span
214
+ style={{
215
+ display: "grid",
216
+ placeItems: "center",
217
+ width: u(40),
218
+ height: u(40),
219
+ marginTop: u(-24),
220
+ borderRadius: "50%",
221
+ background: colors.tone,
222
+ boxShadow: `0 0 0 ${u(4)} ${APP.card}${step === 1 ? `, 0 0 0 ${u(9)} ${hexAlpha(colors.tone, 0.2)}` : ""}`,
223
+ transform: step === 1 ? "scale(0.9)" : "none",
224
+ transition: "transform 0.15s ease, box-shadow 0.3s ease",
225
+ }}
226
+ >
227
+ <Glyph id="bot" size={18} color="#ffffff" />
228
+ </span>
229
+ <span style={{ fontSize: u(7.6), color: colors.tone }}>{t(UI.nav[n], lang)}</span>
230
+ </div>
231
+ ) : (
232
+ <div key={i} style={{ flex: 1, display: "flex", flexDirection: "column", alignItems: "center", gap: u(3), color: n === 0 ? colors.tone : MUTED }}>
233
+ <Glyph id={icon} size={14} color={n === 0 ? colors.tone : MUTED} />
234
+ <span style={{ fontSize: u(7.6) }}>{t(UI.nav[n], lang)}</span>
235
+ </div>
236
+ ),
237
+ )}
238
+ </div>
239
+ </div>
240
+ </div>
241
+ </Stage>
242
+ )
243
+ }
244
+
245
+ function Kicker({ tone, children }: { tone: string; children: ReactNode }) {
246
+ return <div style={{ fontSize: u(7.6), fontWeight: 600, letterSpacing: "0.14em", textTransform: "uppercase", color: tone }}>{children}</div>
247
+ }
248
+
249
+ /** Two states of the same place, crossfading. */
250
+ function Layer({ on, delay = 0, children }: { on: boolean; delay?: number; children: ReactNode }) {
251
+ return (
252
+ <div style={{ position: "absolute", inset: 0, opacity: on ? 1 : 0, transform: on ? "none" : `translateY(${u(6)})`, transition: `opacity 0.4s ease ${on ? delay : 0}s, transform 0.5s ease ${on ? delay : 0}s` }}>
253
+ {children}
254
+ </div>
255
+ )
256
+ }