import { NavLink, Outlet, useLocation } from "react-router-dom"; import { useAuth } from "@/features/auth/AuthProvider"; import { Icon, type IconName } from "@/components/Icon"; import { Ltr } from "@/components/ui"; import { t } from "@/strings/ar"; import AnnouncementBar from "@/components/AnnouncementBar"; /* The rail, per ContiAI App.dc.html. * * It is a dark navy panel rather than a light one, which is the single change * that gives the product its shape: the page floats as one bright field beside * a fixed dark edge, and the active item - brand fill on navy - is legible at * a glance. * * The page is RTL, so the first element in a flex row lands on the RIGHT. The * rail is therefore first in the DOM; putting the main region first pushed the * navigation to the left, which is wrong for Arabic. */ interface NavItem { to: string; label: string; icon: IconName; end?: boolean; } const NAV: NavItem[] = [ { to: "/", label: t.nav.home, icon: "home", end: true }, { to: "/create", label: t.nav.create, icon: "sparkle" }, { to: "/library", label: t.nav.library, icon: "book" }, { to: "/usage", label: t.nav.usage, icon: "clock" }, ]; /** The founder's bag designer - shown to the owner account only. */ const DESIGN: NavItem = { to: "/design", label: "تصميم الحقائب والعروض", icon: "layers" }; /** «استوديو التصميم» - social designs and infographics, the owner account only. */ const STUDIO: NavItem = { to: "/studio", label: "استوديو التصميم", icon: "infographic" }; const FOOT: NavItem[] = [ { to: "/profile", label: "الملف الشخصي", icon: "user" }, { to: "/settings", label: t.nav.settings, icon: "cog" }, ]; /** A rail row. Everything it wears is a rail token - none of the page's text * or surface roles read correctly against navy. */ function Item({ item }: { item: NavItem }) { return ( [ "flex min-h-11 items-center gap-3 rounded-md px-3 py-2.5", "text-item transition-colors duration-200", isActive ? "bg-[var(--color-brand-700)] font-bold text-white" : "font-medium text-[var(--rail-item)] hover:bg-white/[0.07]", ].join(" ") } > {({ isActive }) => ( <> {item.label} )} ); } export default function AppShell() { const { user, isAdmin, canDesign, signOut } = useAuth(); // the designers and the studio: whoever the founder opened them to const designs = canDesign("bag") || canDesign("slides"); const nav = [...NAV, ...(designs ? [DESIGN] : []), ...(canDesign("studio") ? [STUDIO] : [])]; const location = useLocation(); const account = user?.full_name || user?.email?.split("@")[0] || ""; const initial = (account || "؟").trim().charAt(0); return (
{/* rail first == right side in RTL */} {/* key on the path so each screen fades in on navigation */}
{/* On small screens the rail becomes a bottom bar, and it keeps the rail's own colours so the product still reads as itself. */}
); }