import { Show, createEffect, createSignal } from "solid-js"; import { useNavigate } from "@tanstack/solid-router"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { IconBell } from "@/components/ui/icons"; import { cn } from "@/lib/cn"; import { formatUnreadCount } from "@/lib/notifications"; import { createNotificationFeed } from "@/components/layout/notification-feed"; import { NotificationList } from "@/components/layout/notification-list"; import { useT } from "@/stores/preferences-context"; /** The header bell: the notification list in a popover. */ export function NotificationCenter() { const t = useT(); const navigate = useNavigate(); const feed = createNotificationFeed(); const [open, setOpen] = createSignal(false); createEffect(() => { if (open()) { feed.opened(); feed.refreshAll(); } }); const unreadCount = feed.unreadCount; let panel: HTMLDivElement | undefined; return ( 0 ? `${t("notifications.title")} — ${t("notifications.unreadCount", { count: unreadCount() })}` : t("notifications.title") } > 0}> {/* Focus lands on the popover itself, not its first control: that is "Tümünü sil", and one Enter would clear the whole list. */} { panel = el; }} tabIndex={-1} aria-label={t("notifications.title")} onOpenAutoFocus={(event: Event) => { event.preventDefault(); panel?.focus(); }} > { setOpen(false); void navigate({ to: url }); }} /> ); }