videogen/apps/web/components/notifications/NotificationItem.tsx
caelum0x d56639a594
Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

84 lines
2.5 KiB
TypeScript

"use client";
import { cn } from "@/lib/utils";
import type { Notification } from "@/lib/types";
import {
formatRelativeTime,
kindMeta,
notificationHref,
} from "@/components/notifications/format";
interface NotificationItemProps {
notification: Notification;
/**
* Invoked when the row is activated (click / Enter / Space). The parent marks
* it read and deep-links when `notificationHref` resolves a target.
*/
onSelect: (notification: Notification) => void;
}
/**
* A single notification row: kind icon, title, body, and relative time. Unread
* rows carry a subtle highlight and a leading dot. The whole row is an
* accessible button so keyboard users can open it too.
*/
export function NotificationItem({
notification,
onSelect,
}: NotificationItemProps) {
const { icon: Icon, accent } = kindMeta(notification.kind);
const time = formatRelativeTime(notification.created_at);
const hasLink = notificationHref(notification) !== null;
return (
<button
type="button"
onClick={() => onSelect(notification)}
aria-label={`${notification.title}${
notification.read ? "" : " (unread)"
}`}
className={cn(
"flex w-full items-start gap-3 px-4 py-3 text-left transition-colors",
"hover:bg-secondary/50 focus-visible:outline-none focus-visible:bg-secondary/60",
!notification.read && "bg-primary/5",
)}
>
<span className={cn("mt-0.5 shrink-0", accent)}>
<Icon className="size-5" aria-hidden />
</span>
<span className="min-w-0 flex-1">
<span className="flex items-center gap-2">
<span
className={cn(
"truncate text-sm",
notification.read ? "font-medium" : "font-semibold",
)}
>
{notification.title}
</span>
{!notification.read && (
<span
className="ml-auto size-2 shrink-0 rounded-full bg-primary"
aria-hidden
/>
)}
</span>
{notification.body && (
<span className="mt-0.5 line-clamp-2 block text-sm text-muted-foreground">
{notification.body}
</span>
)}
<span className="mt-1 flex items-center gap-2 text-xs text-muted-foreground">
{time && <span>{time}</span>}
{hasLink && (
<span className="text-primary" aria-hidden>
View →
</span>
)}
</span>
</span>
</button>
);
}