Files
OpenStock/components/shell/AppShell.tsx
ahmaddirar-ios 116ec6be67 feat(i18n): Arabic interface with a right-to-left layout (#146)
Arabic as a third language on next-intl: messages/ar.json (469 keys), dir=rtl set before first paint, IBM Plex Sans Arabic only for Arabic, a right-side mobile drawer, logical CSS with LTR unchanged, Arabic TradingView widgets and welcome intro. English and Polish render exactly as before; the public site stays English and static.

Co-Authored-By: ahmaddirar-ios <57848046+ahmaddirar-ios@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 00:51:59 +05:30

64 lines
2.5 KiB
TypeScript

'use client';
import React, { useEffect, useRef, useState } from "react";
import { usePathname } from "next/navigation";
import { useTranslations } from "next-intl";
import Sidebar from "@/components/shell/Sidebar";
import TabBar from "@/components/shell/TabBar";
import SearchCommand from "@/components/SearchCommand";
import { cn } from "@/lib/utils";
import UpdateBanner from "@/components/UpdateBanner";
type AppShellProps = {
user: User;
watchlist: { symbol: string; company: string }[];
initialStocks: StockWithWatchlistStatus[];
children: React.ReactNode;
};
const AppShell = ({ user, watchlist, initialStocks, children }: AppShellProps) => {
const t = useTranslations('UpdateBanner');
const pathname = usePathname();
const [navOpen, setNavOpen] = useState(false);
const workspaceRef = useRef<HTMLElement>(null);
// The workspace is the scroll container, so reset it on navigation
useEffect(() => {
setNavOpen(false);
workspaceRef.current?.scrollTo({ top: 0 });
}, [pathname]);
return (
<div className="shell">
<div
className={cn(
// The drawer slides in from the reading side: the right in Arabic
'min-h-0 max-lg:fixed max-lg:inset-y-0 max-lg:left-0 max-lg:rtl:left-auto max-lg:rtl:right-0 max-lg:z-50 max-lg:w-[272px] max-lg:transition-transform max-lg:duration-200',
navOpen ? 'max-lg:translate-x-0' : 'max-lg:-translate-x-full max-lg:rtl:translate-x-full',
)}
>
<Sidebar user={user} watchlist={watchlist} />
</div>
{navOpen && (
<div className="fixed inset-0 z-40 bg-page/60 backdrop-blur-[2px] lg:hidden" onClick={() => setNavOpen(false)} />
)}
<div className="shell-container">
<div className="app">
<TabBar onMenu={() => setNavOpen(true)} />
<main ref={workspaceRef} className={cn('workspace', pathname === '/dashboard' && 'is-first-tab')}>
<div className="workspace-inner">
<UpdateBanner labels={{ new: t('new'), seeWhatsNew: t('seeWhatsNew'), fullChangelog: t('fullChangelog') }} />
{children}
</div>
</main>
</div>
</div>
<SearchCommand initialStocks={initialStocks} />
</div>
);
};
export default AppShell;