/* UpWeDo landing — "Happening now": four spotlight stats (top routine, top task, done most this week, biggest challenge) and what people work on, from window.LANDING_HIGHLIGHTS / LANDING_TRENDS. Today, this week and the people active are the hero's. The server leaves out anything too small to show; an empty piece simply drops out, and with nothing at all the section is not rendered. */ const { useState } = React; const INK = '#111827', INK_2 = '#4B5563', INK_3 = '#6B7280'; const BLUE = '#2563EB'; const DAY_MS = 86400000; const cardStyle = m => ({ borderRadius:20, padding:m?'20px 16px':'24px 26px', background:'#fff', border:'1px solid rgba(0,0,0,0.05)', boxShadow:'0 12px 40px rgba(27,45,110,0.07)' }); const Tip = ({ children, style }) => (
{children}
); const SrTable = ({ caption, rows }) => ( /* Tables ignore a 1px width, so the clipped box is a wrapper around the table. */
{rows.map(([k,v])=>)}
{caption}
{k}{v}
); /* ── SPOTLIGHT CARDS ────────────────────────────────────────── */ /* One stat per card: what it is, its name, the number, and a line of context. */ function spotlights(H, t, loc, lang) { const n = v => v.toLocaleString(loc); /* The title in the page's language when it has been translated, else the original. */ const title = item => (item.titles && item.titles[lang]) || item.title; const joinNote = item => item.joinedThisWeek > 0 ? { text:fill(t.joined, { n:n(item.joinedThisWeek) }), good:true } : null; const byNote = item => item.creator ? { text:fill(t.by, { name:item.creator }) } : null; const daysLeft = iso => { const days = Math.ceil((new Date(iso) - Date.now()) / DAY_MS); return days <= 1 ? t.lastDay : fill(t.daysLeft, { n:n(days) }); }; return [ H.routine && { key:'routine', icon:'🧭', color:'#8B5CF6', label:t.routine, name:title(H.routine), value:n(H.routine.members), unit:t.members, notes:[joinNote(H.routine), byNote(H.routine)] }, H.task && { key:'task', icon:'✅', color:'#2563EB', label:t.task, name:title(H.task), value:n(H.task.members), unit:t.members, notes:[joinNote(H.task), byNote(H.task)] }, H.doneTask && { key:'doneTask', icon:'🔥', color:'#22C55E', label:t.doneTask, name:title(H.doneTask), value:n(H.doneTask.completions), unit:t.done, notes:[] }, H.challenge && { key:'challenge', icon:'⏳', color:'#F47215', label:t.challenge, name:H.challenge.title, value:n(H.challenge.participants), unit:t.participants, notes:[{ text:daysLeft(H.challenge.endsAt) }] }, ].filter(Boolean).map(c=>({ ...c, notes:c.notes.filter(Boolean) })); } function SpotlightCard({ card, m, wide }) { return (
{card.icon} {card.label}
{card.name}
{card.value} {card.unit}
{card.notes.length > 0 && (
{card.notes.map(note=>( {note.good ? '↑ ' : ''}{note.text} ))}
)}
); } /* ── WHAT PEOPLE WORK ON (horizontal bars, share of the week) ── */ function CategoryBars({ categories, t, lang, loc, m }) { const [hover,setHover] = useState(null); const total = categories.reduce((n,c)=>n+c.completions, 0); const max = categories[0].completions; const name = c => (c.names && c.names[lang]) || c.name; return (
{t.title}
{t.sub}
{categories.map((c,i)=>{ const share = Math.round(c.completions / total * 100); return (
setHover(i)} onMouseLeave={()=>setHover(null)} style={{ position:'relative' }}>
{name(c)} {share}%
{hover===i && {fill(t.value, { n:c.completions.toLocaleString(loc) })}}
); })}
[name(c), c.completions.toLocaleString(loc)])} />
); } /* ── THE SECTION ────────────────────────────────────────────── */ function HappeningNow({ L, lang }) { const m = useIsMobile(); const t = L.happening; const cards = spotlights(window.LANDING_HIGHLIGHTS || {}, t.spot, L.loc, lang); const categories = (window.LANDING_TRENDS || {}).categories || []; if (!cards.length && !categories.length) return null; /* From 1000px, cards in a 2×2 beside the categories (an odd last one spans the row); narrower, the cards wrap at a readable width above the categories. */ const side = useViewportWidth() >= 1000 && cards.length > 0 && categories.length > 0; const kicker = <>{t.kicker}; return (
{cards.length > 0 && (
{cards.map((c,i)=>)}
)} {categories.length > 0 && }
); } Object.assign(window, { HappeningNow });