/* global React, window, Icon, Mascot, Reveal, FloatingDeco, HeroScene, CourseCover, useT, useEyad, ThemeIcon, SUBJECTS, COURSES, PILLARS */
const { useState, useEffect, useRef } = React;
// ============================================================
// NAV — with language + theme toggles
// ============================================================
function Nav({ active, onNav, onSignup }) {
const t = useT();
const { lang, theme, setLang, setTheme } = useEyad();
const links = [
{ id: "why", label: t.nav.why },
{ id: "courses", label: t.nav.courses },
{ id: "journey", label: t.nav.journey },
{ id: "teachers", label: t.nav.teachers },
{ id: "stories", label: t.nav.stories },
];
return (
);
}
// ============================================================
// HERO
// ============================================================
function Hero({ mascotStyle, onSignup, onScrollCourses }) {
const t = useT();
return (
{t.hero.eyebrow}
{t.hero.titleA}
{t.hero.titleB}
{t.hero.titleC}
{t.hero.lead}
{t.hero.chipA}
{t.hero.chipAv}
{t.hero.chipB}
{t.hero.chipBv}
{t.hero.progress}
{t.hero.progressV}
);
}
// ============================================================
// WHY EYAD
// ============================================================
function Why() {
const t = useT();
return (
{t.why.eyebrow}
{t.why.titleA}
{t.why.titleB}
{t.why.lead}
{PILLARS.map((p, i) => (
{t.why.pillars[i].title}
{t.why.pillars[i].desc}
))}
);
}
// ============================================================
// SUBJECTS
// ============================================================
function Subjects({ onSelectSubject }) {
const t = useT();
return (
{t.subjects.eyebrow}
{t.subjects.titleA}
{t.subjects.titleB}
{t.subjects.lead}
{SUBJECTS.map((s, i) => {
const loc = t.subjects.items[s.id];
return (
onSelectSubject(s.id)}>
{s.en}
{loc.name}
{loc.desc}
{t.subjects.discover}
);
})}
);
}
// ============================================================
// COURSES
// ============================================================
function localizeCourse(c, t) {
const o = t.courseOverrides?.[c.id] || {};
return {
...c,
title: o.title || c.title,
short: o.short || c.short,
tag: o.tag || c.tag,
level: o.level || c.level,
age: o.age || c.age,
duration: o.duration || c.duration,
teacher: { ...c.teacher, name: o.teacher || c.teacher.name, role: o.role || c.teacher.role },
curriculum: o.curriculum ? o.curriculum.map((title, i) => ({ t: title, d: o.cd[i] })) : c.curriculum,
};
}
function Courses({ activeSubject, setActiveSubject, onOpenCourse }) {
const t = useT();
const tabs = [
{ id: "all", label: t.courses.all },
...SUBJECTS.map(s => ({ id: s.id, label: t.subjects.items[s.id].name })),
];
const filtered = activeSubject === "all"
? COURSES
: COURSES.filter(c => c.subject === activeSubject);
const counts = SUBJECTS.reduce((acc, s) => {
acc[s.id] = COURSES.filter(c => c.subject === s.id).length;
return acc;
}, { all: COURSES.length });
return (
{t.courses.eyebrow}
{t.courses.titleA}
{t.courses.titleB}
{t.courses.lead}
{tabs.map(tb => (
))}
{filtered.map((cRaw, i) => {
const c = localizeCourse(cRaw, t);
return (
onOpenCourse(c)}>
{c.level}
{c.tag} · {c.titleEn}
{c.title}
{c.short}
{c.duration}
{c.lessons} {t.courses.lesson}
{c.age}
{c.teacher.initials}
{c.teacher.name}
{c.teacher.role}
{c.rating}
);
})}
);
}
// ============================================================
// COURSE MODAL
// ============================================================
function CourseModal({ course, onClose, onEnroll }) {
const t = useT();
useEffect(() => {
const onKey = (e) => { if (e.key === "Escape") onClose(); };
document.body.style.overflow = "hidden";
window.addEventListener("keydown", onKey);
return () => { document.body.style.overflow = ""; window.removeEventListener("keydown", onKey); };
}, [onClose]);
if (!course) return null;
return (
e.stopPropagation()}>
{course.titleEn}
{course.title}
{course.tag}
{course.level}
{course.age}
{course.short}
{course.lessons}
{t.courses.modal.lessons}
{course.duration}
{t.courses.modal.duration}
{course.students.toLocaleString()}
{t.courses.modal.students}
{t.courses.modal.content}
{course.curriculum.map((item, i) => (
-
{i + 1}
{item.t}
{item.d}
))}
);
}
Object.assign(window, { Nav, Hero, Why, Subjects, Courses, CourseModal });