/* UpWeDo phone mockups — localized via `t` (I18N[lang].phone) + `dir`.
Drawn in the app's current look: the blue Royal backdrop with soft
circles, glass cards, pill buttons and a floating pill tab bar. */
const { useState } = React;
const DISPLAY = 'var(--font-family-display)';
const BASE = 'var(--font-family-base)';
const PH_SOFT = 'rgba(255,255,255,0.74)';
const PH_GLASS = 'rgba(255,255,255,0.9)';
const PH_INK = '#111827', PH_INK2 = '#4B5563';
/* One of the five buddies' 168 × 168 busts (boy, girl, boy2, girl2, boy3). */
const buddySrc = key => `${(window.BRAND||{}).buddyBase || 'assets/buddy'}/avatar-${key}.png`;
function PhoneFrame({ children, tilt=0, cls='' }) {
return (
{colors.map((c,i)=>
0?-4:0 }} />)}
);
const initial = name => (name.trim().split(/\s+/).pop() || '?')[0];
const glass = (extra={}) => ({ borderRadius:16, background:PH_GLASS, boxShadow:'0 6px 18px rgba(13,26,66,0.16)', ...extra });
const Check = ({ size=10, color='#fff' }) => (
);
/* A speech bubble beside a buddy; the tail points at the buddy. */
const Bubble = ({ children, size=9.5 }) => (
{children}
);
/* ── HOME (hero): Done or Not today, until the day closes ─────── */
/* Three habits are left today (two of five are already done). Done ticks
one off; Not today sets it aside with no guilt; when none are left, the
day closes. Numbers are illustrative. */
const HOME_QUEUE = [ { crowd:412 }, { crowd:96 }, { crowd:1840 } ];
const HOME_ROUTINES = [ { done:1, total:2, color:'#8B5CF6' }, { done:0, total:1, color:'#22C55E' }, { done:1, total:2, color:'#F47215' } ];
const HOME_TOTAL = HOME_ROUTINES.reduce((n,g)=>n+g.total, 0);
const DONE_FLASH_MS = 650;
function HomePhone({ t, dir='ltr', loc='en-US' }) {
const [results,setResults] = useState([]); // 'done' | 'skip', one per handled item
const [flash,setFlash] = useState(null);
const [tried,setTried] = useState(false);
const step = results.length;
const finished = step >= HOME_QUEUE.length;
const doneIn = gi => HOME_ROUTINES[gi].done + results.filter((r,i)=>r==='done' && i===gi).length;
const doneCount = HOME_ROUTINES.reduce((n,_,gi)=>n+doneIn(gi), 0);
const act = kind => {
if (flash) return;
setTried(true); setFlash(kind);
setTimeout(()=>{ setFlash(null); setResults(r=>[...r, kind]); }, DONE_FLASH_MS);
};
const item = HOME_QUEUE[step], copy = t.queue[step];
const num = v => v.toLocaleString(loc);
return (
{t.greeting}
✦ {t.quote}
{finished ? (
{t.allDone}
{!results.includes('skip') &&
{t.allDoneSub}
}
📅 {t.activeDays}
✦ {t.finishedWith}
) : (
{t.upNext}
{copy.task}
{copy.source}
{flash==='skip' ? t.skipNote : fill(flash==='done' ? t.you : t.crowd, { n:item.crowd.toLocaleString(loc) })}
)}
{Array.from({ length:HOME_TOTAL }, (_,i)=>
)}
{fill(t.progress, { done:num(doneCount), total:num(HOME_TOTAL) })}
{!tried &&
👆 {t.tryIt}}
{t.todayLabel}
{HOME_ROUTINES.map((g,gi)=>{
const done = doneIn(gi), complete = done===g.total;
return (
{t.routines[gi]}
{num(done)}/{num(g.total)}{complete?' ✓':''}
);
})}
);
}
/* ── THE CROWD: a habit's community count and a challenge ───── */
const CROWD_WEEK = [52, 64, 58, 71, 66, 48, 80];
function CrowdPhone({ t, dir='ltr' }) {
const c = t.crowdScreen;
return (
{c.title}
{c.week}
{CROWD_WEEK.map((h,i)=>(
))}
{c.challengeMeta}
{c.challengeCount}
);
}
/* ── YOUR BUDDY: the day closed, a keepsake, and the buddy's word ─ */
function BuddyPhone({ t, dir='ltr' }) {
const c = t.buddyScreen;
return (
{c.greeting}
{t.allDone}
📅 {t.activeDays}
🏅
{c.keepsakeLabel}
{c.keepsake}
{c.says}
);
}
/* ── YOUR GUIDE: a creator's routine with their tip ─────────── */
function GuidePhone({ t, dir='ltr' }) {
const c = t.guideScreen;
return (
{initial(c.creator)}
{c.creator}
✓ {c.verified}
{c.routine}
{c.meta}
{c.steps.map((s,i)=>(
{i+1}
{s}
))}
{c.join}
);
}
Object.assign(window, { PhoneFrame, HomePhone, CrowdPhone, BuddyPhone, GuidePhone, buddySrc, Bubble });