diff --git a/web/next-app/app/home/sections.tsx b/web/next-app/app/home/sections.tsx
index 85931f21e..4d8cf7290 100644
--- a/web/next-app/app/home/sections.tsx
+++ b/web/next-app/app/home/sections.tsx
@@ -2,329 +2,456 @@
import Link from 'next/link'
import { useEffect, useRef, useState } from 'react'
+import { useRouter } from 'next/navigation'
import { LOGIN_HERO } from '../../lib/loginHero'
-import {
- PIPELINE_STATES,
- conceptCount,
- domainCounts,
- domainLabels,
- domainOrder,
- levels,
-} from './data'
+import { FEATURED_FIGURES } from '../../lib/featuredFigures'
+import VisualFigure from '../../components/visual/VisualFigure'
+import { API_BASE, getConfig, googleOneTap } from '../../lib/api'
+import { establishSession } from '../../lib/auth'
+import { conceptCount, domainCounts, domainLabels, domainOrder } from './data'
+
+// The homepage keeps the drawing and the type of the rest of the app. The
+// landing page is the one place with a painting, so the buttons on it carry a
+// white hairline and every other control keeps the themed border.
-// The two hero actions. They are written out in full rather than composed, because
-// the ghost button used to be the primary button plus overrides and the two
-// background utilities (`bg-mathua-blue` and `bg-transparent`, `hover:bg-mathua-blue-hover`
-// and `hover:bg-white/15`) collided: same property, same specificity, so the winner was
-// whichever Tailwind emitted last and the GitHub button hovered to blue on the image.
-// Separate constants with no overlapping property cannot collide. Both actions are
-// content-width and left-aligned on phones: as full-width bars with only the page's
-// 16px gutters they read as touching the screen edges.
const CTA_PRIMARY =
'inline-flex min-h-[44px] items-center justify-center bg-mathua-blue px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-mathua-blue-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-mathua-blue'
-// On the artwork the second action is a white hairline over a dark scrim, not the
-// themed surface border: a `mathua-border` line is tuned for the page background,
-// not for a photograph, and would disappear against the drawing.
-// Wipe-fill ghost: on hover a blue layer sweeps left to right behind the label
-// (origin-left scale-x). The fill lives on a child span, not the anchor, so the
-// anchor never carries two background utilities at once, the collision that once
-// turned this button blue. `overflow-hidden` clips the sweep; the label sits
-// `relative` above it.
+
const CTA_GHOST_ON_ART =
- 'group relative inline-flex min-h-[44px] items-center justify-center overflow-hidden border border-white/45 bg-transparent px-6 py-3 text-sm font-medium text-white transition-colors hover:border-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white'
+ 'group relative inline-flex min-h-[44px] items-center justify-center overflow-hidden border border-white/45 bg-transparent px-6 py-3 text-sm font-medium text-white transition-colors hover:border-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white lg:border-mathua-border lg:text-mathua-primary lg:hover:border-mathua-blue lg:focus-visible:outline-mathua-blue'
+
+function GhostLabel({ children }: { children: React.ReactNode }) {
+ return (
+ <>
+
+ {children}
+ >
+ )
+}
+
+interface GoogleAccounts {
+ initialize: (options: {
+ client_id: string
+ callback: (response: { credential?: string }) => void
+ auto_select?: boolean
+ cancel_on_tap_outside?: boolean
+ }) => void
+ prompt: () => void
+}
+
+interface GoogleWindow extends Window {
+ google?: { accounts?: { id?: GoogleAccounts } }
+}
+
+/**
+ * The Learn call to action opens this panel instead of navigating straight
+ * away. Google One Tap is destroyed by a navigation and can be suppressed by
+ * FedCM, so the prompt has to run on the page that shows it. The panel always
+ * keeps a guest link, which is the path that cannot fail.
+ */
+function StartPanel({ onClose }: { onClose: () => void }) {
+ const router = useRouter()
+ const [prompted, setPrompted] = useState(false)
+ const [busy, setBusy] = useState(false)
+ const started = useRef(false)
+
+ useEffect(() => {
+ if (started.current) return
+ started.current = true
+ let cancelled = false
+
+ async function start() {
+ try {
+ const cfg = await getConfig()
+ const clientID = (cfg?.google_client_id || '').trim()
+ if (!clientID || cancelled) return
+ const src = 'https://accounts.google.com/gsi/client'
+ if (!document.querySelector(`script[src="${src}"]`)) {
+ await new Promise((resolve, reject) => {
+ const script = document.createElement('script')
+ script.src = src
+ script.async = true
+ script.defer = true
+ script.onload = () => resolve()
+ script.onerror = () => reject(new Error('gis unavailable'))
+ document.head.appendChild(script)
+ })
+ }
+ if (cancelled) return
+ const g = (window as GoogleWindow).google
+ if (!g?.accounts?.id) return
+ g.accounts.id.initialize({
+ client_id: clientID,
+ callback: async (resp) => {
+ if (!resp?.credential) return
+ setBusy(true)
+ try {
+ const data = await googleOneTap(resp.credential)
+ await establishSession(data.token, {
+ student_id: data.student_id,
+ name: data.name,
+ username: '',
+ concepts_mastered: 0,
+ current_streak: 0,
+ level: 'Novice',
+ diagnostic_completed: data.diagnostic_completed,
+ })
+ router.push('/learn')
+ } catch {
+ setBusy(false)
+ }
+ },
+ auto_select: false,
+ cancel_on_tap_outside: true,
+ })
+ g.accounts.id.prompt()
+ setPrompted(true)
+ } catch {
+ // One Tap is optional. The two links below are the working paths.
+ }
+ }
+
+ void start()
+ return () => {
+ cancelled = true
+ }
+ }, [router])
+
+ return (
+
+
Start learning
+
+ {busy
+ ? 'Signing you in…'
+ : prompted
+ ? 'Choose an account in the Google prompt, or continue as a guest.'
+ : 'Continue with Google to keep progress across devices, or start as a guest.'}
+
+ )
+}
-export function HeroSection({ onGetStarted }: { onGetStarted: () => void }) {
+export function HeroSection() {
+ const [panelOpen, setPanelOpen] = useState(false)
return (
- // One responsive hero, not two stacked variants. Below lg it is the full-bleed
- // treatment (B): art behind the copy under a scrim. At lg and up it is the
- // side-by-side panel (A): copy left, art right, scrim gone and copy back on
- // theme tokens. A single h1 and a single img serve both, no duplicated
- // heading, no second download.
- //
- // The section sits in the page's capped, padded column, so the picture is a
- // banner aligned to the content rather than a window-wide bleed, every other
- // section shares that column, and a hero that ignored it would be the odd one
- // out. `isolate` keeps the background's stacking context local so it cannot
- // paint over the sticky header.
- {/* Art. Full-bleed backdrop below lg; the grid's right column at lg and up.
- `lg:relative` re-seats it as a grid item while the img keeps filling it
- with object-cover, and `lg:order-2` puts it right of the copy. DOM order
- stays art-first so that on phones, where both layers are positioned,
- the copy paints above the picture.
- The picture never touches the header: `top-4` holds it off the section
- top on phones, `lg:mt-10` on desktop (`lg:top-auto lg:bottom-auto` cancel
- the phone offsets once it is a grid item). */}
-
+
- {/* Phone scrim only: it darkens the text side and fades toward the art, so
- the copy has contrast without flattening the drawing. Stronger than the
- earlier wash, because phone copy spans the full frame. */}
-
+
-
( 01 · Title Block )
+
( 01 · Title Block )
- Adaptive math learning platform
+ Don’t just finish mathematics. Understand it.
- Mathua is an open-source adaptive math learning engine. You cannot advance until you
- have truly mastered the prerequisite, both speed and accuracy must be proven.
+ Mathua adapts to what you know, strengthens what you don’t, and makes sure you master the foundations
+ before moving forward.
+ No account needed. Progress stays on this device.
+
+ {panelOpen && setPanelOpen(false)} />}
+
)
}
-// Counts up when the stat scrolls into view. The target is rendered first so
-// no-JS, reduced-motion, and e2e reads always see the real number; the
-// observer restarts it from 0 only once the element is (barely) on screen.
-function CountUp({ target, duration = 1200 }: { target: number; duration?: number }) {
- const ref = useRef(null)
- useEffect(() => {
- const el = ref.current
- if (!el) return
- if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return
- let raf = 0
- const observer = new IntersectionObserver(
- entries => {
- if (!entries[0]?.isIntersecting) return
- observer.disconnect()
- const start = performance.now()
- const tick = (now: number) => {
- const t = Math.min(1, (now - start) / duration)
- const eased = 1 - Math.pow(1 - t, 3)
- el.textContent = String(Math.round(eased * target))
- if (t < 1) raf = requestAnimationFrame(tick)
- }
- raf = requestAnimationFrame(tick)
- },
- { threshold: 0 }
- )
- observer.observe(el)
- return () => {
- observer.disconnect()
- cancelAnimationFrame(raf)
- }
- }, [target, duration])
- return {target}
+const PRACTICE = {
+ question: 'What is 7 × 8?',
+ options: [54, 56, 58, 64],
+ answer: 56,
+ working: '7 × 8 = 56. The multiplication table row for 7 lands on 56 at the eighth step.',
}
-export function TrustSection() {
+/** A real question, answered locally, in the same markup as a lesson card. */
+export function PracticePreview() {
+ const [picked, setPicked] = useState(null)
+ const correct = picked === PRACTICE.answer
return (
-
-
( 02 · Why it is trusted )
-
-
- Open-source under MIT. Sequencing inspired by Math Academy, with MIT OpenCourseWare and
- Art of Problem Solving consulted for curriculum structure and problem quality. Lessons
- build on OpenStax (CC BY-NC-SA 4.0) and Algebrica (CC BY-NC 4.0). No accounts to start,
- no paywall on the graph.
-
+ A concept is mastered from recent evidence: accuracy, speed, variety and time since the last attempt.
+
+
)
}
-const FEATURES = [
- {
- numeral: 'I.',
- title: 'Mastery gating',
- body: 'You cannot advance until your streak and response time both meet the threshold. Knowing the answer is not enough; you must know it fast.',
- },
- {
- numeral: 'II.',
- title: 'Concept graph',
- body: 'Every concept is a node with explicit prerequisites. Mathua reads the graph and your progress together, and picks what you see next from the two.',
- },
- {
- numeral: 'III.',
- title: 'Spaced repetition',
- body: 'Concepts you master resurface automatically before they decay. Reviews are woven into your session; there is no separate review mode.',
- },
+const STEPS = [
+ { title: 'Learn', body: 'A short lesson introduces the idea and works one example. The figure and the algebra stay on the same screen.' },
+ { title: 'Practice', body: 'Problems are generated for the concept, so you cannot memorise one set of answers and move on.' },
+ { title: 'Master', body: 'Mastery needs a run of correct answers at the target speed, across different forms of the same idea.' },
+ { title: 'Review', body: 'What you mastered comes back on a schedule, before it fades, rather than all at once.' },
]
-export function FeaturesSection() {
+export function StepsSection() {
return (
-
-
( 03 · 3 Main Features )
-
- {FEATURES.map(f => (
-
-
{f.numeral}
-
{f.title}
-
{f.body}
+
+
( 03 · How learning works )
+
+ {STEPS.map((step, index) => (
+
+ {String(index + 1).padStart(2, '0')}
+
{step.title}
+
{step.body}
))}
+
+ How the engine decides →
+
)
}
-const chipClass = (status: string) => {
- if (status === 'mastered') return 'border border-mathua-blue bg-mathua-blue text-mathua-bg'
- if (status === 'decaying') return 'border border-dashed border-mathua-border text-mathua-primary'
- return 'border border-mathua-border text-mathua-primary'
-}
-
-export function StatesSection() {
+export function FiguresSection() {
return (
-
- The scheduler enforces three hard rules: prerequisites must be mastered before a concept
- unlocks, the same concept never appears twice in a row and roughly 70% of each session
- is new material.
-
+
+ More about the interactive figures →
+
)
}
-function DomainTable({ rows }: { rows: [string, number][] }) {
+const ADAPTIVE = [
+ {
+ title: 'Prerequisites are enforced',
+ body: 'A concept unlocks only when the ideas under it are mastered. The map is a check, not a suggestion.',
+ },
+ {
+ title: 'Mastery is evidence',
+ body: 'Correctness alone is not enough. Speed, variety across question forms and the time since the last attempt all count.',
+ },
+ {
+ title: 'Review is scheduled',
+ body: 'Mastered ideas return on a spacing schedule built from how quickly each one was answered.',
+ },
+]
+
+export function AdaptiveSection() {
return (
-
+ Mathua is MIT licensed. Lessons draw on OpenStax (CC BY-NC-SA 4.0) and Algebrica (CC BY-NC 4.0), and the
+ engine, generators and interface are in one repository. You can read it, run it, or change it.
+
+ A short diagnostic finds the edge of what you can do, and the plan starts there.
+
+
+
+ Start learning for free
+
+
+ Create an account
+
+
)
@@ -332,66 +459,35 @@ export function RankingSection() {
const FAQS = [
{
- q: 'Do I need an account to start?',
- a: 'No. Begin studying immediately, accounts are optional and only needed to sync progress across devices.',
+ q: 'Do I need an account?',
+ a: 'No. Guest practice works in the browser. An account keeps progress across devices and lets reminders reach you.',
},
{
- q: 'Why does speed matter, not just accuracy?',
- a: 'Fluency requires retrieval under time pressure. Knowing the answer is not enough; you must know it fast, or the foundation will not hold the next concept.',
+ q: 'Why does speed count?',
+ a: 'A mastered fact is one you can use without stopping to rebuild it. The check measures a run of correct answers at a target pace, not a single lucky answer.',
},
{
- q: 'When does a mastery check appear?',
- a: 'After enough learning XP. The short check verifies what you have learned; concepts you have already mastered return through spaced review instead.',
- },
- {
- q: 'Is Mathua free and open-source?',
- a: 'Yes, MIT licensed, with no paywall on the graph. Every concept and generator is in the repository.',
+ q: 'Is it free?',
+ a: 'Yes. Mathua is MIT licensed and has no paywall. You can also self-host it.',
},
]
export function FaqSection() {
return (
-
-
-
( 07 · Questions, answered. )
-
- {FAQS.map(f => (
-
-
- {f.q}
- +
-
-
{f.a}
-
- ))}
-
-
-
-
( 08 · How it is extended. )
-
- Every concept is a JSON node. Every problem is a Go generator function. Every
- contribution goes through a graph validator that rejects cycles and orphaned nodes
- automatically.
-
)
diff --git a/web/next-app/app/page.tsx b/web/next-app/app/page.tsx
index adc2de20d..9016f7211 100644
--- a/web/next-app/app/page.tsx
+++ b/web/next-app/app/page.tsx
@@ -1,51 +1,52 @@
'use client'
-import { useRouter } from 'next/navigation'
-import { useTheme } from '../hooks/useTheme'
+import Footer from '../components/Footer'
+import Header from '../components/Header'
import { useHomeRedirect } from '../hooks/useHomeRedirect'
import { useScrollReveal } from '../hooks/useScrollReveal'
-import Header from '../components/Header'
-import Footer from '../components/Footer'
+import { useTheme } from '../hooks/useTheme'
import {
+ AdaptiveSection,
+ ClosingCta,
CoverageSection,
FaqSection,
- FeaturesSection,
+ FiguresSection,
HeroSection,
- RankingSection,
- StatesSection,
- TrustSection,
+ OpenSourceSection,
+ PracticePreview,
+ StepsSection,
} from './home/sections'
+const LINKS = [
+ { label: 'Learn', href: '/learn' },
+ { label: 'How it works', href: '/how-it-works' },
+ { label: 'Docs', href: '/docs' },
+ { label: 'Note', href: '/note' },
+ { label: 'Leaderboard', href: '/leaderboard' },
+ { label: 'Login', href: '/login' },
+]
+
export default function HomePage() {
const { mounted } = useTheme()
- const { push } = useRouter()
- // Logged-in visits bounce to /profile; explicit Home clicks stay put.
const homeChecked = useHomeRedirect(mounted)
- // Sections only exist once the redirect check resolves, so gate on it.
useScrollReveal(mounted && homeChecked)
if (!mounted || !homeChecked) {
return
}
- function handleGetStarted() {
- push('/login')
- }
-
return (
<>
- {/* The landing hardcodes its own header rather than inheriting lib/nav.ts,
- because a marketing page wants Docs and How it works inline. Learn is
- still listed first: the primary destination of the product should not
- vanish on the page that introduces it. */}
-
+
-
-
-
-
+
+
+
+
+
-
+
+
diff --git a/web/next-app/e2e/mobile.spec.ts b/web/next-app/e2e/mobile.spec.ts
index 6d3e8d90f..ed1722688 100644
--- a/web/next-app/e2e/mobile.spec.ts
+++ b/web/next-app/e2e/mobile.spec.ts
@@ -44,26 +44,25 @@ for (const route of ROUTES) {
})
}
-test('landing FAQ and extension columns stay inside the viewport', async ({ page }) => {
+test('landing FAQ stays inside the viewport', async ({ page }) => {
await page.goto('/')
const section = page.locator('section', { hasText: 'Questions, answered' })
await section.scrollIntoViewIfNeeded()
const vw = page.viewportSize()!.width
- // Regression: the JSON pre's min-content used to widen the grid track past
- // the container, so main's overflow-x-clip cut off the FAQ text and code.
- for (const child of await section.locator('> div').all()) {
+ await expect(section.locator('details')).toHaveCount(3)
+
+ // The extension column and its JSON pre left the landing page with the
+ // redesign. The regression they guarded, a min-content track widening the
+ // section past the viewport, still applies to every direct child here.
+ const children = section.locator('> *')
+ expect(await children.count()).toBeGreaterThan(0)
+ for (const child of await children.all()) {
const box = await child.boundingBox()
expect(box).toBeTruthy()
expect(box!.x).toBeGreaterThanOrEqual(0)
expect(box!.x + box!.width).toBeLessThanOrEqual(vw + 1)
}
-
- const pre = section.locator('pre')
- const box = await pre.boundingBox()
- expect(box).toBeTruthy()
- expect(box!.x).toBeGreaterThanOrEqual(0)
- expect(box!.x + box!.width).toBeLessThanOrEqual(vw + 1)
})
test('bottom tabs present and scroll-aware on mobile', async ({ page }) => {
diff --git a/web/next-app/test/homeGetStarted.test.tsx b/web/next-app/test/homeGetStarted.test.tsx
deleted file mode 100644
index 8801a6432..000000000
--- a/web/next-app/test/homeGetStarted.test.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { fireEvent, render, screen } from '@testing-library/react'
-import { describe, expect, it, vi } from 'vitest'
-import HomePage from '../app/page'
-
-const { push, ensureGuestToken, ensureGuestId } = vi.hoisted(() => ({
- push: vi.fn(),
- ensureGuestToken: vi.fn(),
- ensureGuestId: vi.fn(),
-}))
-
-vi.mock('next/navigation', () => ({ useRouter: () => ({ push }) }))
-vi.mock('../lib/auth', () => ({ ensureGuestId, ensureGuestToken }))
-vi.mock('../hooks/useTheme', () => ({ useTheme: () => ({ mounted: true }) }))
-vi.mock('../hooks/useHomeRedirect', () => ({ useHomeRedirect: () => true }))
-vi.mock('../hooks/useScrollReveal', () => ({ useScrollReveal: () => {} }))
-vi.mock('../components/Header', () => ({ default: () => null }))
-vi.mock('../components/Footer', () => ({ default: () => null }))
-// Only the hero matters here; the rest of the landing is copy.
-vi.mock('../app/home/sections', () => ({
- HeroSection: ({ onGetStarted }: { onGetStarted: () => void }) => (
-
- ),
- TrustSection: () => null,
- FeaturesSection: () => null,
- StatesSection: () => null,
- CoverageSection: () => null,
- RankingSection: () => null,
- FaqSection: () => null,
-}))
-
-// Reported as "Get started page won't load on desktop". The page was fine: the
-// click waited for the guest token before navigating, so a stalled token request
-// (a filtered or blocked API origin) kept the button dead for the request's full
-// ten-second timeout. Navigation must not depend on it.
-describe('Get started', () => {
- it('opens the learn page without waiting for the guest token', () => {
- ensureGuestToken.mockReturnValue(new Promise(() => {})) // never settles
- render()
-
- fireEvent.click(screen.getByRole('button', { name: 'Get started' }))
-
- expect(push).toHaveBeenCalledWith('/login')
- expect(ensureGuestId).not.toHaveBeenCalled()
- expect(ensureGuestToken).not.toHaveBeenCalled()
- })
-})
diff --git a/web/next-app/test/landingHero.test.tsx b/web/next-app/test/landingHero.test.tsx
index 9e8093317..05f05dc52 100644
--- a/web/next-app/test/landingHero.test.tsx
+++ b/web/next-app/test/landingHero.test.tsx
@@ -21,10 +21,11 @@ vi.mock('../lib/auth', async (importOriginal) => {
}
})
-// The hero's "Get started" is the most prominent action on the marketing page.
-// It used to send a signed-out visitor to /profile, an empty dashboard with a
+// The hero's primary action opens the start panel rather than navigating.
+// A signed-out visitor used to land on /profile, an empty dashboard with a
// zeroed heatmap and no question anywhere on it, which is a poor first
-// experience and the opposite of Learn being the primary destination.
+// experience and the opposite of Learn being the primary destination. The
+// panel keeps the click for One Tap while always offering the guest path.
describe('landing hero', () => {
beforeEach(() => {
localStorage.clear()
@@ -34,21 +35,22 @@ describe('landing hero', () => {
vi.mocked(ensureGuestId).mockClear()
})
- it('sends "Get started" to Login', async () => {
+ it('opens the start panel instead of leaving the page', async () => {
render()
- const cta = await screen.findByRole('button', { name: 'Get started' })
+ const cta = await screen.findByRole('button', { name: 'Start learning for free' })
cta.click()
- await waitFor(() => expect(pushMock).toHaveBeenCalledWith('/login'))
- expect(pushMock).not.toHaveBeenCalledWith('/profile')
+ expect(await screen.findByTestId('start-panel')).toBeInTheDocument()
+ expect(screen.getByRole('link', { name: 'Continue as a guest' })).toHaveAttribute('href', '/learn')
+ expect(pushMock).not.toHaveBeenCalled()
})
- it('does not mint a guest identity when opening Login', async () => {
+ it('does not mint a guest identity when the start panel opens', async () => {
render()
- ;(await screen.findByRole('button', { name: 'Get started' })).click()
- await waitFor(() => expect(pushMock).toHaveBeenCalledWith('/login'))
+ ;(await screen.findByRole('button', { name: 'Start learning for free' })).click()
+ await screen.findByTestId('start-panel')
// The anchor that grades the first answer is keyed by student, and the
// practice endpoint only resolves one from a bearer token, so the guest
- // id and token have to exist before /learn fetches anything.
+ // id and token are minted by /learn, not by the landing page.
expect(ensureGuestId).not.toHaveBeenCalled()
expect(ensureGuestToken).not.toHaveBeenCalled()
})
@@ -61,8 +63,8 @@ describe('landing hero', () => {
it('keeps the two hero actions on separate, non-conflicting backgrounds', async () => {
render()
- const primary = await screen.findByRole('button', { name: 'Get started' })
- const ghost = await screen.findByRole('link', { name: 'View on GitHub' })
+ const primary = await screen.findByRole('button', { name: 'Start learning for free' })
+ const ghost = await screen.findByRole('link', { name: 'See how it works' })
// The ghost button was once the primary button plus overrides, so both
// `bg-mathua-blue` and `bg-transparent` (and both hover backgrounds) sat on one
// element. Same property, same specificity: Tailwind's emitted order decided the