From 06ced750061363a294b3d488dc1a3f0ba258a8d6 Mon Sep 17 00:00:00 2001 From: jyswee Date: Thu, 23 Jul 2026 22:12:19 +0000 Subject: [PATCH] Seed: education template (18 files) --- src/components/Header.tsx | 128 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 src/components/Header.tsx diff --git a/src/components/Header.tsx b/src/components/Header.tsx new file mode 100644 index 0000000..c19cdc6 --- /dev/null +++ b/src/components/Header.tsx @@ -0,0 +1,128 @@ +import { useState, useEffect } from "react"; +import { Link } from "react-router-dom"; +import { Button } from "@/components/ui/button"; +import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet"; +import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogTrigger } from "@/components/ui/dialog"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Menu, GraduationCap } from "lucide-react"; +import { ThemeToggle } from "@/components/ThemeToggle"; +import { useAuth } from "@/hooks/use-tygarun"; +import { toast } from "sonner"; + +function AuthDialog({ trigger }: { trigger: React.ReactNode }) { + const { signin, signup, isSignedIn, signout, user } = useAuth(); + const [open, setOpen] = useState(false); + const [mode, setMode] = useState<"signin" | "signup">("signin"); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [busy, setBusy] = useState(false); + + if (isSignedIn) { + return ( + + ); + } + + const submit = async (e: React.FormEvent) => { + e.preventDefault(); + setBusy(true); + try { + if (mode === "signup") await signup({ email, password }); + else await signin(email, password); + toast.success(mode === "signup" ? "Account created!" : "Welcome back!"); + setOpen(false); + } catch { toast.error("Authentication failed. Please try again."); } + finally { setBusy(false); } + }; + + return ( + + {trigger} + + + {mode === "signup" ? "Create your account" : "Sign in"} + {mode === "signup" ? "Start learning in minutes." : "Access your courses and progress."} + +
+
+ + setEmail(e.target.value)} placeholder="you@example.com" required /> +
+
+ + setPassword(e.target.value)} placeholder="••••••••" required /> +
+ +
+ +
+
+ ); +} + +export default function Header() { + const [open, setOpen] = useState(false); + const [scrolled, setScrolled] = useState(false); + + useEffect(() => { + const fn = () => setScrolled(window.scrollY > 20); + window.addEventListener("scroll", fn); + return () => window.removeEventListener("scroll", fn); + }, []); + + const links = [ + { label: "Courses", to: "/courses" }, + { label: "Instructors", to: "/instructors" }, + { label: "Pricing", to: "/courses" }, + { label: "Contact", to: "/contact" }, + ]; + + return ( +
+
+ +
+ +
+ Luminar Academy + + +
+ + Sign In} /> + +
+ + + + + + + + +
+
+ ); +} \ No newline at end of file