"use client"; import "./components/ui/tidal.css"; import { useCallback, useId, useLayoutEffect, useMemo, useRef, useState } from "react"; import { TidalActivityFeed, type TidalActivityFeedGroup, type TidalActivityFeedItem } from "./components/ui/activity-feed"; import "./components/ui/activity-feed.css"; function tidalExampleAvatarDataUri(seed: unknown) { const text = String(seed).replace(/[^a-z0-9]/gi, "").slice(-2) || "UI"; const palette = ["#333333", "#555555", "#777777", "#999999", "#bbbbbb"]; const color = palette[Array.from(text).reduce((sum, character) => sum + character.charCodeAt(0), 0) % palette.length]; const svg = ``; return `data:image/svg+xml,${encodeURIComponent(svg)}`; } function tidalExampleImageDataUri(label: string) { const safeLabel = label.replace(/[<>&]/g, "").slice(0, 28) || "Sample image"; const svg = `${safeLabel}`; return `data:image/svg+xml,${encodeURIComponent(svg)}`; } const tidalExampleStyles = ".tidal-scope .activity-feed-demo,\n.tidal-scope .activity-feed-demo * {\n box-sizing: border-box;\n}\n\n.tidal-scope .activity-feed-demo {\n width: 100%;\n min-width: 0;\n border: 1px solid var(--t-border);\n border-radius: 22px;\n background: var(--t-subtle);\n color: var(--t-ink);\n container: activity-feed-demo / inline-size;\n}\n\n.tidal-scope .activity-feed-demo-layout {\n display: grid;\n min-width: 0;\n grid-template-columns: minmax(0, 1fr) minmax(250px, 0.42fr);\n gap: 14px;\n padding: 20px;\n}\n\n.tidal-scope .activity-feed-demo-detail {\n position: sticky;\n top: 14px;\n min-width: 0;\n min-height: 360px;\n align-self: start;\n padding: 24px;\n border: 1px solid var(--t-border);\n border-radius: 18px;\n background: var(--t-ink);\n color: var(--t-surface);\n outline: none;\n}\n\n.tidal-scope .activity-feed-demo-detail:focus-visible {\n outline: 2px solid var(--t-accent);\n outline-offset: 3px;\n}\n\n.tidal-scope .activity-feed-demo-detail > span {\n color: color-mix(in srgb, var(--t-surface) 62%, var(--t-ink));\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.1em;\n line-height: 1.35;\n text-transform: uppercase;\n}\n\n.tidal-scope .activity-feed-demo-detail-topline {\n display: flex;\n min-width: 0;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n margin-top: 22px;\n padding-bottom: 12px;\n border-bottom: 1px solid\n color-mix(in srgb, var(--t-surface) 24%, var(--t-ink));\n color: color-mix(in srgb, var(--t-surface) 68%, var(--t-ink));\n font-size: 11px;\n line-height: 1.35;\n}\n\n.tidal-scope .activity-feed-demo-detail-topline strong,\n.tidal-scope .activity-feed-demo-detail-topline time {\n min-width: 0;\n overflow-wrap: anywhere;\n}\n\n.tidal-scope .activity-feed-demo-detail h3 {\n margin: 25px 0 0;\n font-size: clamp(25px, 5cqi, 38px);\n font-weight: 530;\n letter-spacing: -0.052em;\n line-height: 1.03;\n text-wrap: balance;\n overflow-wrap: anywhere;\n}\n\n.tidal-scope .activity-feed-demo-detail p {\n margin: 15px 0 0;\n color: color-mix(in srgb, var(--t-surface) 72%, var(--t-ink));\n font-size: 11px;\n line-height: 1.65;\n overflow-wrap: anywhere;\n}\n\n.tidal-scope .activity-feed-demo-detail dl {\n display: grid;\n gap: 1px;\n margin: 23px 0 0;\n overflow: hidden;\n border: 1px solid color-mix(in srgb, var(--t-surface) 22%, var(--t-ink));\n border-radius: 10px;\n background: color-mix(in srgb, var(--t-surface) 22%, var(--t-ink));\n}\n\n.tidal-scope .activity-feed-demo-detail dl > div {\n min-width: 0;\n padding: 10px 11px;\n background: var(--t-ink);\n}\n\n.tidal-scope .activity-feed-demo-detail dt {\n color: color-mix(in srgb, var(--t-surface) 58%, var(--t-ink));\n font-size: 11px;\n line-height: 1.35;\n}\n\n.tidal-scope .activity-feed-demo-detail dd {\n margin: 4px 0 0;\n font-size: 11px;\n line-height: 1.4;\n overflow-wrap: anywhere;\n}\n\n@container activity-feed-demo (max-width: 760px) {\n .tidal-scope .activity-feed-demo-layout {\n grid-template-columns: minmax(0, 1fr);\n padding: 10px;\n }\n\n .tidal-scope .activity-feed-demo-detail {\n position: static;\n min-height: 0;\n }\n}\n\n@container activity-feed-demo (max-width: 390px) {\n .tidal-scope .activity-feed-demo-layout {\n gap: 9px;\n padding: 7px;\n }\n\n .tidal-scope .activity-feed-demo-detail {\n padding: 20px 16px;\n }\n}"; type FilterId = "all" | "unread" | "comment" | "change"; type SampleItem = Omit & { groupId: "today" | "earlier"; kind: Exclude; detail: string; }; const INITIAL_ITEMS: readonly SampleItem[] = [ { id: "brief-comment", groupId: "today", kind: "comment", title: "Ava left a note on the sample brief", dateTime: "2026-10-14T09:24:00-05:00", timeLabel: "9:24 AM", description: "The local note asks whether the launch checklist should appear beside the brief.", category: "Comment", context: "Project brief", unread: true, actor: { name: "Ava Stone", detail: "Fictional teammate", avatarSrc: tidalExampleAvatarDataUri("01"), }, detail: "Ava’s fictional note suggests placing the checklist beside the project brief so both sample files can be reviewed together.", }, { id: "milestone-change", groupId: "today", kind: "change", title: "Noah moved the review milestone", dateTime: "2026-10-14T08:10:00-05:00", timeLabel: "8:10 AM", description: "The fictional due label changed from Wednesday to Friday in local sample data.", category: "Change", context: "Launch plan", unread: true, actor: { name: "Noah Park", detail: "Fictional teammate", avatarSrc: tidalExampleAvatarDataUri("02"), }, detail: "The sample milestone now reads Friday. No calendar event, task, or remote record was changed.", }, { id: "checklist-comment", groupId: "today", kind: "comment", title: "Mila answered the checklist question", dateTime: "2026-10-14T07:42:00-05:00", timeLabel: "7:42 AM", description: "The answer references the fictional launch checklist included with this preview.", category: "Comment", context: "Checklist", unread: false, actor: { name: "Mila Santos", detail: "Fictional teammate", avatarSrc: tidalExampleAvatarDataUri("03"), }, detail: "Mila’s sample answer confirms that every checklist item remains visible in the local document example.", }, { id: "status-change", groupId: "earlier", kind: "change", title: "Eli changed the sample status to review", dateTime: "2026-10-13T16:18:00-05:00", timeLabel: "Yesterday", description: "The status word updates only this fictional feed and its local detail panel.", category: "Change", context: "Workspace sample", unread: false, actor: { name: "Eli Brooks", detail: "Fictional teammate", avatarSrc: tidalExampleAvatarDataUri("04"), }, detail: "The fictional workspace status is Review. This preview has no connected workspace, account, or backend.", }, ]; export function ActivityFeedDemo() { const generatedId = useId().replace(/:/g, ""); const detailId = `activity-feed-${generatedId}-detail`; const [filter, setFilter] = useState("all"); const [items, setItems] = useState(INITIAL_ITEMS); const [selectedId, setSelectedId] = useState(INITIAL_ITEMS[0].id); const [message, setMessage] = useState( "Choose an activity title or filter. All changes stay in local preview state.", ); const filterNodes = useRef(new Map()); const pendingFilterFocus = useRef(null); const allFilterRef = useCallback((node: HTMLButtonElement | null) => { if (node) filterNodes.current.set("all", node); else filterNodes.current.delete("all"); }, []); const unreadFilterRef = useCallback((node: HTMLButtonElement | null) => { if (node) filterNodes.current.set("unread", node); else filterNodes.current.delete("unread"); }, []); const commentFilterRef = useCallback((node: HTMLButtonElement | null) => { if (node) filterNodes.current.set("comment", node); else filterNodes.current.delete("comment"); }, []); const changeFilterRef = useCallback((node: HTMLButtonElement | null) => { if (node) filterNodes.current.set("change", node); else filterNodes.current.delete("change"); }, []); useLayoutEffect(() => { const target = pendingFilterFocus.current; if (!target) return; pendingFilterFocus.current = null; filterNodes.current.get(target)?.focus({ preventScroll: true }); }, [items]); const visible = useMemo( () => items.filter((item) => { if (filter === "all") return true; if (filter === "unread") return item.unread; return item.kind === filter; }), [filter, items], ); const groups = useMemo(() => { const renderItem = (item: SampleItem): TidalActivityFeedItem => ({ ...item, destination: { href: `#${detailId}`, label: `Open local detail for ${String(item.title)}`, linkProps: { onClick: () => { setSelectedId(item.id); setMessage( `${String(item.title)} opened in the local detail panel.`, ); }, }, }, actions: [ { kind: "button", id: "toggle-read", label: item.unread ? "Mark read" : "Mark unread", buttonProps: { "aria-pressed": !item.unread }, onAction: () => { if (filter === "unread" && item.unread) { pendingFilterFocus.current = "unread"; } setItems((current) => current.map((candidate) => candidate.id === item.id ? { ...candidate, unread: !candidate.unread } : candidate, ), ); setMessage( `${String(item.title)} marked ${item.unread ? "read" : "unread"} in local preview state.`, ); }, }, ], }); return [ { id: "today", label: "Today", items: visible .filter((item) => item.groupId === "today") .map(renderItem), }, { id: "earlier", label: "Earlier", items: visible .filter((item) => item.groupId === "earlier") .map(renderItem), }, ]; }, [detailId, filter, visible]); const selected = items.find((item) => item.id === selectedId) ?? items[0]; const countFor = (id: FilterId) => items.filter((item) => { if (id === "all") return true; if (id === "unread") return item.unread; return item.kind === id; }).length; return (
{ setFilter(value as FilterId); setMessage(`Showing ${value} activity in local preview state.`); }, }} footer={ {message} No notification, request, task, or remote record is sent. } />
Local activity detail
{selected.category}

{selected.title}

{selected.detail}

Fictional actor
{selected.actor?.name ?? "System sample"}
Context
{selected.context}
Read state
{selected.unread ? "Unread" : "Read"}
); } export default function AgentExample() { return (
); }