Skip to content

feat: dynamic hero backgrounds per indigenous language - #21

Merged
pablonification merged 1 commit into
mainfrom
feat/language-backgrounds
May 9, 2026
Merged

pablonification merged 1 commit into
mainfrom
feat/language-backgrounds

Conversation

@hsbu

@hsbu hsbu commented May 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add LANGUAGE_COUNTRY and LANGUAGE_BG maps to learningLanguages.ts; LANGUAGE_BG uses import.meta.glob to eagerly bundle 20 per-country background images (learner + elder variants) and resolves the correct one from the user's chosen indigenous language
  • Replace static background-learner.png / background-elder.png imports in LandingPage.tsx with a LANGUAGE_BG[learningLanguage] lookup; learningLanguage prop now flows into ElderLanding as well
  • Add 20 country-specific background images under assets/landing/background/ (Indonesia, Malaysia, Thailand, Cambodia, Philippines, Vietnam, Singapore, Myanmar + Brunei, Laos for future languages)
  • Add ::after dark overlay (rgba(0,0,0,0.32)) on .landing-hero so text and badges remain legible against brighter backgrounds

Test plan

  • Log in as a Learner with learning language set to each of the 8 supported languages — hero image should match the selected country
  • Log in as an Elder — elder-variant background should load for the matching language
  • Change language in Profile → Settings → Language and navigate back to Home — background should update
  • Verify greeting text and language badge are readable over the overlay
  • All 123 unit tests pass (npm run test:run)

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented May 9, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR adds per-language dynamic hero backgrounds to the landing page by mapping each of the 8 supported indigenous languages to a country-specific background image (learner + elder variants). It also tightens the hero overlay with a rgba(0,0,0,0.32) dark wash and updates the greeting text color to #ffedd6 for legibility against the new images.

  • Adds import.meta.glob in learningLanguages.ts to eagerly bundle all 16 PNGs at build time and exposes a LANGUAGE_BG record keyed by LearningLanguage.
  • Replaces static bgLearner/bgElder imports in LandingPage.tsx with LANGUAGE_BG[learningLanguage] lookups; learningLanguage prop is now threaded into ElderLanding as well.
  • Adds a ::after CSS overlay on .landing-hero (z-index 1, below the z-index 2/3 greeting and badge) so text remains readable over brighter country-specific images.

Confidence Score: 5/5

Safe to merge — the change swaps two static image imports for a glob-based lookup; TypeScript enforces that every LearningLanguage key has a corresponding entry in LANGUAGE_BG, so the image access cannot be undefined at call sites.

All 8 supported languages have matching PNG files committed for both roles, the z-index layering in the CSS overlay is correct, and the learningLanguage prop is properly threaded down to both LearnerLanding and ElderLanding. No logic paths are left without a valid image URL through the type-guaranteed lookup.

No files require special attention. src/lib/learningLanguages.ts has a previously-discussed empty-string fallback, but that was flagged in an earlier review thread.

Important Files Changed

Filename Overview
src/lib/learningLanguages.ts Adds import.meta.glob eager bundle for background PNGs and the LANGUAGE_BG lookup map; fallback returns an empty string on key miss (already flagged in a prior thread). LEARNING_LANGUAGE_METADATA already stores country names making the language→country mapping a second source of truth.
src/pages/LandingPage.tsx Removes static background imports, narrows learningLanguage prop type to LearningLanguage, and threads it into ElderLanding; LANGUAGE_BG lookup is always valid because the type system guarantees a key exists.
src/pages/LandingPage.css Adds ::after dark overlay (z-index 1) inside the hero stacking context; greeting (z-index 2) and badge (z-index 3) remain correctly above it. Greeting color updated to #ffedd6 with text-shadow removed.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[LandingPage mounts] --> B[resolveLearningLanguage\nfrom user profile]
    B --> C{isElder?}
    C -- Yes --> D[ElderLanding\nlearningLanguage prop]
    C -- No --> E[LearnerLanding\nlearningLanguage prop]
    D --> F[LANGUAGE_BG\nlanguage .elder]
    E --> G[LANGUAGE_BG\nlanguage .learner]
    F --> H[import.meta.glob\neager bundle lookup]
    G --> H
    H --> I[Resolved PNG URL\nfrom assets/landing/background/]
    I --> J[img src rendered\nin .landing-hero]
    J --> K[::after overlay\nrgba 0,0,0,0.32 z-index 1]
    K --> L[Greeting span\nz-index 2]
    K --> M[LearningLanguageBadge\nz-index 3]
Loading

Reviews (2): Last reviewed commit: "feat: switch landing backgrounds by lang..." | Re-trigger Greptile

Comment thread src/lib/learningLanguages.ts Resolved
Comment thread src/lib/learningLanguages.ts Resolved
@pablonification
pablonification force-pushed the feat/language-backgrounds branch from 21e833c to a05c2bb Compare May 9, 2026 18:33
@pablonification
pablonification merged commit 9d967ae into main May 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants