"use client"; import "./components/ui/tidal.css"; import { useId, useLayoutEffect, useMemo, useRef, useState } from "react"; import { RotateCcw } from "lucide-react"; import { TidalBlogGrid, type TidalBlogArticle } from "./components/ui/blog-grid"; import "./components/ui/blog-grid.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 .blog-grid-demo {\n display: grid;\n width: min(100%, 1040px);\n min-width: 0;\n gap: 18px;\n margin-inline: auto;\n}\n\n.tidal-scope .blog-grid-demo-empty {\n display: grid;\n gap: 12px;\n justify-items: center;\n}\n\n.tidal-scope .blog-grid-demo-empty strong {\n color: var(--t-ink);\n}\n\n.tidal-scope .blog-grid-demo-empty button {\n display: inline-flex;\n min-width: 44px;\n min-height: 44px;\n align-items: center;\n justify-content: center;\n gap: 7px;\n padding: 8px 12px;\n color: var(--t-surface);\n background: var(--t-ink);\n border: 1px solid var(--t-ink);\n border-radius: var(--t-radius-control);\n font: inherit;\n font-size: 11px;\n cursor: pointer;\n}\n\n.tidal-scope .blog-grid-demo-detail {\n min-width: 0;\n padding: 22px;\n color: var(--t-surface);\n background: var(--t-ink);\n border-radius: var(--t-radius-card);\n scroll-margin-block: 18px;\n}\n\n.tidal-scope .blog-grid-demo-detail:focus-visible {\n outline: 2px solid var(--t-accent);\n outline-offset: 3px;\n}\n\n.tidal-scope .blog-grid-demo-detail > span {\n color: color-mix(in srgb, var(--t-surface) 68%, transparent);\n font-size: 11px;\n font-weight: 760;\n letter-spacing: 0.13em;\n text-transform: uppercase;\n}\n\n.tidal-scope .blog-grid-demo-detail h3 {\n margin: 8px 0 0;\n overflow-wrap: anywhere;\n font-size: 24px;\n line-height: 1;\n letter-spacing: -0.04em;\n}\n\n.tidal-scope .blog-grid-demo-detail p {\n max-width: 72ch;\n margin: 11px 0 0;\n color: color-mix(in srgb, var(--t-surface) 74%, transparent);\n font-size: 11px;\n line-height: 1.6;\n overflow-wrap: anywhere;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tidal-scope .blog-grid-demo-empty button:active {\n transform: none;\n }\n}"; type CategoryId = "all" | "design" | "engineering" | "workflow"; interface SampleArticle extends Omit { categoryId: Exclude; body: string; } const ARTICLES: readonly SampleArticle[] = [ { id: "reviewing-motion", title: "Reviewing motion without losing the interface", categoryId: "design", category: "Design", date: { label: "Oct 14, 2026", dateTime: "2026-10-14" }, excerpt: "A product note about checking continuity, focus, and reduced motion together.", featured: true, cover: , author: { name: "Ava Stone", role: "Fictional editor", avatar: { src: tidalExampleAvatarDataUri("01") }, }, meta: "5 min read", body: "Review motion alongside focus order and reduced-motion behavior so transitions support the interface instead of obscuring it.", }, { id: "native-controls", title: "Why native controls still carry the hard parts", categoryId: "engineering", category: "Engineering", date: { label: "Oct 11, 2026", dateTime: "2026-10-11" }, excerpt: "A short note on forms, keyboard behavior, and application-owned state.", cover: , author: { name: "Noah Park", role: "Fictional engineer", avatar: { src: tidalExampleAvatarDataUri("02") }, }, meta: "4 min read", body: "Native controls preserve familiar keyboard, form, and browser behavior while leaving application outcomes to the product.", }, { id: "small-screen", title: "A small-screen review is a product review", categoryId: "workflow", category: "Workflow", date: { label: "Oct 8, 2026", dateTime: "2026-10-08" }, excerpt: "Field notes for evaluating real controls before decorative polish.", cover: , author: { name: "Mila Santos", role: "Fictional reviewer", avatar: { src: tidalExampleAvatarDataUri("03") }, }, meta: "3 min read", body: "Small-screen review reveals crowded controls, unstable focus, and hidden overflow before decorative polish makes them harder to isolate.", }, { id: "honest-demos", title: "Building demos that explain their boundary", categoryId: "workflow", category: "Workflow", date: { label: "Oct 4, 2026", dateTime: "2026-10-04" }, excerpt: "An editorial note about local state, clear labels, and explicit outcomes.", cover: , author: { name: "Eli Brooks", role: "Fictional writer", avatar: { src: tidalExampleAvatarDataUri("04") }, }, meta: "6 min read", body: "A useful demo labels its boundary once, then lets real controls and visible local outcomes explain the interaction.", }, { id: "tokens", title: "Keeping a neutral token system expressive", categoryId: "design", category: "Design", date: { label: "Sep 29, 2026", dateTime: "2026-09-29" }, excerpt: "A design note on rhythm, contrast, surfaces, and controlled variation.", cover: , meta: "4 min read", body: "A neutral token system can stay expressive through spacing, hierarchy, contrast, and a small set of deliberate surface changes.", }, ]; export function BlogGridDemo() { const generatedId = useId().replace(/:/g, ""); const [query, setQuery] = useState(""); const [category, setCategory] = useState("all"); const [activeId, setActiveId] = useState(null); const searchRef = useRef(null); const resetFocusPending = useRef(false); const normalized = query.trim().toLocaleLowerCase(); const visible = useMemo( () => ARTICLES.filter( (article) => (category === "all" || article.categoryId === category) && (!normalized || `${article.title} ${article.categoryId} ${String(article.excerpt)}` .toLocaleLowerCase() .includes(normalized)), ), [category, normalized], ); const counts = useMemo( () => new Map( (["all", "design", "engineering", "workflow"] as CategoryId[]).map( (id) => [ id, ARTICLES.filter( (article) => (id === "all" || article.categoryId === id) && (!normalized || `${article.title} ${article.categoryId} ${String(article.excerpt)}` .toLocaleLowerCase() .includes(normalized)), ).length, ], ), ), [normalized], ); const active = ARTICLES.find((article) => article.id === activeId); const detailId = `blog-demo-${generatedId}-detail`; useLayoutEffect(() => { if (!resetFocusPending.current) return; resetFocusPending.current = false; searchRef.current?.focus({ preventScroll: true }); }, [category, query]); const renderedArticles: readonly TidalBlogArticle[] = visible.map( (article) => ({ ...article, href: `#${detailId}`, linkProps: { onClick: () => setActiveId(article.id) }, }), ); function reset() { resetFocusPending.current = true; setQuery(""); setCategory("all"); setActiveId(null); } return (
setCategory(id as CategoryId), }} emptyMessage={
No local article matches
} footer="Sample articles. Search and filters stay in this preview." />
{active ? (
Article detail

{active.title}

{active.body}

) : null}
); } function CoverArt({ variant }: { variant: number }) { const offset = 22 + variant * 7; return ( ); } export default function AgentExample() { return (
); }