Author SHA1 Message Date
ahp 4d2c060a29 feat(web): account menu in the header instead of an inline email
The email sat in the header row next to Sign out, truncated on medium
screens and hidden on small ones.

- an avatar with the email's initial opens a menu with the full email
  and Sign out
- the menu closes on outside click and Escape, returns focus to the
  avatar, and opens towards the inline end so it fits in RTL and LTR
- accounts without a known email get a generic avatar and "Signed in"
2026-11-26 17:58:31 +03:30
5 changed files with 128 additions and 25 deletions

No files matched your search

+3
View File
@@ -82,6 +82,9 @@ The format follows [Keep a Changelog](https://keepachangelog.com/) and the proje
under it. Applied across LICENSE, both READMEs, CITATION.cff, both
pyproject.toml files, web/package.json, the landing site copy, the demo
Space metadata and the fine-tuned model card.
- The header shows the signed-in account as an avatar with the email's
initial. It opens a menu with the full email and Sign out, instead of a
truncated email that disappeared on narrow screens.
### Fixed
+4 -2
View File
@@ -18,8 +18,10 @@
"switchToFa": "فارسی",
"signIn": "Sign in",
"signOut": "Sign out",
"signedInAs": "Signed in as {email}",
"signOutOf": "Sign out of {email}"
"accountMenu": "Account",
"accountMenuFor": "Account menu for {email}",
"signedInLabel": "Signed in as",
"signedIn": "Signed in"
},
"landing": {
"headline": "From speech to text, in moments",
+4 -2
View File
@@ -18,8 +18,10 @@
"switchToFa": "فارسی",
"signIn": "ورود",
"signOut": "خروج",
"signedInAs": "واردشده با {email}",
"signOutOf": "خروج از حساب {email}"
"accountMenu": "حساب کاربری",
"accountMenuFor": "منوی حساب {email}",
"signedInLabel": "وارد شده با",
"signedIn": "وارد شده‌ای"
},
"landing": {
"headline": "از گفتار به متن، در چند لحظه",
+114
View File
@@ -0,0 +1,114 @@
"use client";
import { useEffect, useId, useRef, useState } from "react";
import { useTranslations } from "next-intl";
import { ChevronDown, LogOut, UserRound } from "lucide-react";
/**
* The signed-in account in the header: an avatar with the email's initial
* that opens a small menu showing the full address and Sign out. The full
* email no longer has to squeeze into the header row (where it was
* truncated or hidden on narrow screens).
*/
export function AccountMenu({
email,
signingOut,
onSignOut,
}: {
email: string | null;
signingOut: boolean;
onSignOut: () => void;
}) {
const t = useTranslations("nav");
const [open, setOpen] = useState(false);
const rootRef = useRef<HTMLDivElement>(null);
const buttonRef = useRef<HTMLButtonElement>(null);
const signOutRef = useRef<HTMLButtonElement>(null);
const menuId = useId();
useEffect(() => {
if (!open) return;
signOutRef.current?.focus();
function onPointerDown(event: PointerEvent) {
if (!rootRef.current?.contains(event.target as Node)) setOpen(false);
}
function onKeyDown(event: KeyboardEvent) {
if (event.key === "Escape") {
setOpen(false);
buttonRef.current?.focus();
}
}
document.addEventListener("pointerdown", onPointerDown);
document.addEventListener("keydown", onKeyDown);
return () => {
document.removeEventListener("pointerdown", onPointerDown);
document.removeEventListener("keydown", onKeyDown);
};
}, [open]);
const initial = email ? email.charAt(0).toUpperCase() : null;
return (
<div ref={rootRef} className="relative">
<button
ref={buttonRef}
type="button"
onClick={() => setOpen((value) => !value)}
aria-haspopup="menu"
aria-expanded={open}
aria-controls={open ? menuId : undefined}
aria-label={email ? t("accountMenuFor", { email }) : t("accountMenu")}
className="flex items-center gap-1 rounded-full p-0.5 text-stone-500 transition-colors hover:text-stone-800 focus-visible:ring-2 focus-visible:ring-teal-700 focus-visible:ring-offset-2"
>
<span
className="flex h-9 w-9 items-center justify-center rounded-full bg-teal-100 text-sm font-bold text-teal-800"
aria-hidden="true"
>
{initial ?? <UserRound className="h-5 w-5" />}
</span>
<ChevronDown
className={`hidden h-4 w-4 transition-transform sm:block ${open ? "rotate-180" : ""}`}
aria-hidden="true"
/>
</button>
{open ? (
<div
id={menuId}
role="menu"
aria-label={t("accountMenu")}
className="absolute end-0 top-full z-50 mt-2 w-64 overflow-hidden rounded-xl border border-stone-200 bg-white shadow-lg"
>
<div className="border-b border-stone-100 px-4 py-3">
<p className="text-xs text-stone-500">{email ? t("signedInLabel") : t("accountMenu")}</p>
{email ? (
<p
dir="ltr"
className="mt-0.5 break-all text-start text-sm font-medium text-stone-900"
>
{email}
</p>
) : (
<p className="mt-0.5 text-sm font-medium text-stone-900">{t("signedIn")}</p>
)}
</div>
<button
ref={signOutRef}
type="button"
role="menuitem"
onClick={() => {
setOpen(false);
onSignOut();
}}
disabled={signingOut}
className="flex w-full items-center gap-2 px-4 py-2.5 text-sm font-medium text-stone-700 transition-colors hover:bg-stone-50 hover:text-stone-900 focus-visible:bg-stone-50 focus-visible:outline-none disabled:opacity-60"
>
<LogOut className="h-4 w-4 rtl:-scale-x-100" aria-hidden="true" />
{t("signOut")}
</button>
</div>
) : null}
</div>
);
}
+3 -21
View File
@@ -2,7 +2,8 @@
import { useState } from "react";
import { useLocale, useTranslations } from "next-intl";
import { AudioLines, LogIn, LogOut } from "lucide-react";
import { AudioLines, LogIn } from "lucide-react";
import { AccountMenu } from "@/components/account-menu";
import { Link, usePathname, useRouter } from "@/i18n/navigation";
import { logout } from "@/lib/api";
import { useSession } from "@/lib/session";
@@ -73,26 +74,7 @@ export function SiteHeader() {
{otherLocale === "en" ? "EN" : "فا"}
</button>
{ready && signedIn && (
<>
{email && (
<span
className="hidden max-w-48 truncate text-sm text-stone-500 md:inline"
title={t("signedInAs", { email })}
>
{email}
</span>
)}
<button
type="button"
onClick={handleSignOut}
disabled={signingOut}
aria-label={email ? t("signOutOf", { email }) : t("signOut")}
className="inline-flex items-center gap-1.5 rounded-lg px-2 py-2 text-sm font-medium text-stone-600 transition-colors hover:bg-stone-100 hover:text-stone-900 focus-visible:ring-2 focus-visible:ring-teal-700 disabled:opacity-60 sm:px-3"
>
<LogOut className="h-4 w-4 rtl:-scale-x-100" aria-hidden="true" />
<span className="hidden sm:inline">{t("signOut")}</span>
</button>
</>
<AccountMenu email={email} signingOut={signingOut} onSignOut={handleSignOut} />
)}
{ready && !signedIn && pathname !== "/login" && (
<Link