Skip to content

Commit 690f854

Browse files
feat(mobile): dedicated, interactive phone home screen
Phones now render a purpose-built MobileHome tree instead of a squeezed desktop layout. page.tsx picks ONE tree via a JS breakpoint (not a CSS hidden/block split) so the heavy R3F WebGL constellation never mounts on mobile — the main source of jank on low-end phones. MobileHome is single-column, touch-first: big tappable domain cards, a horizontal snap "rising this week" carousel, quick-question console, vertical how-it-works timeline, and the 5-minute plan front-and-center. Reveals use Framer Motion whileInView (reliable on mobile) instead of GSAP ScrollTrigger. Critically, entrance animations are now fail-safe: content only starts hidden once a visible tab is confirmed (canAnimate gate); otherwise it paints at its visible resting state. No element can be stranded invisible if an animation never fires — the exact bug class that broke phones before. Same guard applied to FiveMinutePlan. DashboardShell gains an opt-in flushX so the mobile tree owns all horizontal spacing (edge-to-edge carousels). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 21dc3bb commit 690f854

4 files changed

Lines changed: 453 additions & 6 deletions

File tree

‎frontend/src/app/page.tsx‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import LiveConstellation from "@/components/3d/LiveConstellation";
3333
import DashboardShell from "@/components/DashboardShell";
3434
import ContinueLearning from "@/components/ContinueLearning";
3535
import FiveMinutePlan from "@/components/FiveMinutePlan";
36+
import MobileHome from "@/components/MobileHome";
3637

3738
/* ─── Helper for Relative Time ─── */
3839
function getRelativeTime(isoString: string): string {
@@ -129,6 +130,21 @@ export default function HomePage() {
129130
const [isLoading, setIsLoading] = useState<boolean>(true);
130131
const [error, setError] = useState<string | null>(null);
131132

133+
/* ─── Device split ───
134+
Render EITHER the mobile tree OR the desktop tree — never both. A CSS-only
135+
`hidden`/`md:block` split would still mount the desktop's R3F WebGL
136+
constellation offscreen on phones (janking low-end devices); this keeps the
137+
heavy desktop bits from ever mounting on mobile. Starts false so SSR/first
138+
paint matches, then corrects post-hydration. */
139+
const [isMobile, setIsMobile] = useState<boolean>(false);
140+
useEffect(() => {
141+
const mq = window.matchMedia("(max-width: 767px)");
142+
const sync = () => setIsMobile(mq.matches);
143+
sync();
144+
mq.addEventListener("change", sync);
145+
return () => mq.removeEventListener("change", sync);
146+
}, []);
147+
132148
// Interactive Comparison Framework State — index into the real top-3 tools
133149
const [compareIdx, setCompareIdx] = useState(0);
134150

@@ -293,6 +309,20 @@ export default function HomePage() {
293309
domains: overview?.domains || domains.length || 0,
294310
}), [overview, tools, domains]);
295311

312+
if (isMobile) {
313+
return (
314+
<DashboardShell fullWidth flushX>
315+
<MobileHome
316+
tools={tools}
317+
domains={domains}
318+
movers={topGainers}
319+
overview={overview}
320+
isLoading={isLoading}
321+
/>
322+
</DashboardShell>
323+
);
324+
}
325+
296326
return (
297327
<DashboardShell fullWidth>
298328
<div ref={containerRef} className="relative pb-24">

‎frontend/src/components/DashboardShell.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ interface DashboardShellProps {
77
children: React.ReactNode;
88
/** Hide the sidebar and use full-width layout */
99
fullWidth?: boolean;
10+
/** Drop horizontal padding so the child controls all x-spacing (edge-to-edge
11+
mobile layouts / full-bleed carousels). Top padding (navbar clearance) stays. */
12+
flushX?: boolean;
1013
/** Per-page accent theme: "teal" | "graphite" | "clay" | "wine" (comparison mode) */
1114
theme?: "teal" | "graphite" | "clay" | "wine";
1215
}
1316

14-
export default function DashboardShell({ children, fullWidth = false, theme }: DashboardShellProps) {
17+
export default function DashboardShell({ children, fullWidth = false, flushX = false, theme }: DashboardShellProps) {
1518
const spotlightRef = useRef<HTMLDivElement>(null);
1619

1720
// Cursor spotlight tracking (inspired by XR reference)
@@ -61,7 +64,7 @@ export default function DashboardShell({ children, fullWidth = false, theme }: D
6164
renders UNDERNEATH the header — most pages hid this behind large hero
6265
padding, but any page whose first element sits high (e.g. the roadmap
6366
back-link) collided with the nav links. */}
64-
<div className={`relative z-10 mx-auto ${fullWidth ? 'max-w-[1400px]' : 'max-w-6xl'} px-4 md:px-6 lg:px-8 pt-[5.5rem] md:pt-24 pb-6 md:pb-8`}>
67+
<div className={`relative z-10 mx-auto ${fullWidth ? 'max-w-[1400px]' : 'max-w-6xl'} ${flushX ? 'px-0' : 'px-4 md:px-6 lg:px-8'} pt-[5.5rem] md:pt-24 pb-6 md:pb-8`}>
6568
{children}
6669
</div>
6770
</main>

‎frontend/src/components/FiveMinutePlan.tsx‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ export default function FiveMinutePlan() {
2727
const [roadmap, setRoadmap] = useState<Roadmap | null>(null);
2828
const cache = useRef<Map<string, Roadmap>>(new Map());
2929

30+
/* Fail-safe entrance: the goal buttons must be visible even if the entrance
31+
animation never fires (hidden tab, reduced-motion, stalled rAF). Gate the
32+
hidden `initial` on a confirmed-visible tab; otherwise paint them visible.
33+
This is the conversion centerpiece — it can never be blank. */
34+
const [canAnimate, setCanAnimate] = useState(false);
35+
useEffect(() => {
36+
if (typeof document === "undefined") return;
37+
if (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
38+
if (document.visibilityState === "visible") { setCanAnimate(true); return; }
39+
const onVis = () => { if (document.visibilityState === "visible") setCanAnimate(true); };
40+
document.addEventListener("visibilitychange", onVis);
41+
return () => document.removeEventListener("visibilitychange", onVis);
42+
}, []);
43+
3044
const pick = useCallback((g: Goal) => {
3145
setPicked(g);
3246
const hit = cache.current.get(g.slug);
@@ -62,7 +76,7 @@ export default function FiveMinutePlan() {
6276
{!picked ? (
6377
<motion.div
6478
key="chooser"
65-
initial={{ opacity: 0, y: 8 }}
79+
initial={canAnimate ? { opacity: 0, y: 8 } : false}
6680
animate={{ opacity: 1, y: 0 }}
6781
exit={{ opacity: 0, y: -8 }}
6882
transition={{ duration: 0.35 }}
@@ -80,7 +94,7 @@ export default function FiveMinutePlan() {
8094
<motion.button
8195
key={g.slug}
8296
onClick={() => pick(g)}
83-
initial={{ opacity: 0, y: 12 }}
97+
initial={canAnimate ? { opacity: 0, y: 12 } : false}
8498
animate={{ opacity: 1, y: 0 }}
8599
transition={{ delay: i * 0.05, duration: 0.4 }}
86100
className="group flex items-center gap-3 p-4 rounded-2xl border border-indigo-500/15 bg-[var(--c-surface)]/70 hover:border-indigo-400/50 hover:bg-[var(--c-surface-2)] hover:shadow-lg hover:shadow-indigo-500/10 transition-all duration-300 text-left active:scale-[0.98] cursor-pointer"
@@ -97,7 +111,7 @@ export default function FiveMinutePlan() {
97111
) : (
98112
<motion.div
99113
key="result"
100-
initial={{ opacity: 0, scale: 0.97 }}
114+
initial={canAnimate ? { opacity: 0, scale: 0.97 } : false}
101115
animate={{ opacity: 1, scale: 1 }}
102116
exit={{ opacity: 0, scale: 0.97 }}
103117
transition={{ duration: 0.4, ease: "easeOut" }}
@@ -130,7 +144,7 @@ export default function FiveMinutePlan() {
130144
{roadmap.steps.slice(0, 3).map((s, i) => (
131145
<motion.div
132146
key={s.step}
133-
initial={{ opacity: 0, x: -12 }}
147+
initial={canAnimate ? { opacity: 0, x: -12 } : false}
134148
animate={{ opacity: 1, x: 0 }}
135149
transition={{ delay: 0.15 + i * 0.12, duration: 0.35 }}
136150
className="flex items-center gap-3 p-3 rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)]/60"

0 commit comments

Comments
 (0)