"use client"; import "./components/ui/tidal.css"; import { useId, useMemo, useRef, useState } from "react"; import { TidalHelpCenterTemplate, type TidalHelpCenterAction } from "./components/ui/help-center-template"; import type { TidalSearchFilter, TidalSearchResult, TidalSearchResultGroup } from "./components/ui/search-results"; import type { TidalFaqGroup } from "./components/ui/faq-section"; import "./components/ui/search-results.css"; import "./components/ui/faq-section.css"; import "./components/ui/help-center-template.css"; import "./components/ui/accordion.css"; const tidalExampleStyles = ".help-center-template-demo,\n.help-center-template-demo * {\n box-sizing: border-box;\n}\n\n.help-center-template-demo {\n width: 100%;\n min-width: 0;\n container: help-center-demo / inline-size;\n}\n\n.help-center-template-demo-notes {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 10px;\n margin-top: 20px;\n}\n\n.help-center-template-demo-notes article,\n.help-center-template-demo-contact {\n min-width: 0;\n padding: 18px;\n border: 1px solid var(--t-border);\n border-radius: 14px;\n background: var(--t-subtle);\n color: var(--t-muted);\n}\n\n.help-center-template-demo-notes article:focus-visible,\n.help-center-template-demo-contact:focus-visible {\n outline: 2px solid var(--t-accent);\n outline-offset: 3px;\n}\n\n.help-center-template-demo-notes span,\n.help-center-template-demo-contact > span {\n color: var(--t-muted);\n font-size: 11px;\n font-weight: 720;\n letter-spacing: 0.1em;\n text-transform: uppercase;\n}\n\n.help-center-template-demo-notes h2,\n.help-center-template-demo-contact h2 {\n margin: 7px 0 0;\n color: var(--t-ink);\n font-size: 18px;\n line-height: 1.15;\n overflow-wrap: anywhere;\n}\n\n.help-center-template-demo-notes p,\n.help-center-template-demo-contact p {\n margin: 8px 0 0;\n font-size: 11px;\n line-height: 1.55;\n overflow-wrap: anywhere;\n}\n\n.help-center-template-demo-contact {\n margin-top: 10px;\n background: var(--t-ink);\n color: color-mix(in srgb, var(--t-surface) 72%, var(--t-ink));\n}\n\n.help-center-template-demo-contact > span,\n.help-center-template-demo-contact h2 {\n color: var(--t-surface);\n}\n\n@container help-center-demo (max-width: 560px) {\n .help-center-template-demo-notes {\n grid-template-columns: minmax(0, 1fr);\n }\n}"; type ResultType = "all" | "guide" | "policy"; interface HelpArticle { id: string; title: string; description: string; type: Exclude; typeLabel: string; time: string; body: string; } const HELP_ARTICLES: readonly HelpArticle[] = [ { id: "workspace-basics", title: "Set up a sample workspace", description: "Arrange the project list and choose a starting view.", type: "guide", typeLabel: "Guide", time: "4 min", body: "Start with one project, give it a clear name, and add only the teammates who need the sample view.", }, { id: "review-files", title: "Review shared files", description: "Open a file, inspect its notes, and return to the library.", type: "guide", typeLabel: "Guide", time: "3 min", body: "Use the file detail view to read supplied notes before returning to the same filtered library position.", }, { id: "sample-access", title: "Sample access policy", description: "Understand how the fictional preview labels access states.", type: "policy", typeLabel: "Policy", time: "2 min", body: "Access labels in this preview describe local sample state only. They do not grant an account or share a resource.", }, { id: "archive-notes", title: "Archive notes policy", description: "See what the local archive example retains on screen.", type: "policy", typeLabel: "Policy", time: "2 min", body: "The archive example changes the visible local list. It does not retain, delete, or recover a real file.", }, ]; const FAQ_GROUPS: readonly TidalFaqGroup[] = [ { id: "workspace", label: "Workspace", description: "Starting and organizing the local sample.", questions: [ { value: "workspace-name", title: "Can I rename the sample workspace?", searchText: "workspace name rename", answer: "Yes. In this preview, renaming updates local React state only and does not create an account or workspace.", }, { value: "workspace-people", title: "Does adding a teammate send an invitation?", searchText: "teammate invite people", answer: "No. Fictional teammate choices remain inside the preview and do not send an invitation.", }, ], }, { id: "files", label: "Files", description: "Reviewing supplied sample documents.", questions: [ { value: "files-download", title: "Which files can I open?", searchText: "open download sample files", answer: "Only the explicitly labelled sample documents and in-page notes included with this library are available.", }, { value: "files-storage", title: "Are changes stored after reload?", searchText: "stored saved reload persistence", answer: "No. The connected examples use local component state and reset when the preview reloads.", }, ], }, ]; export function HelpCenterTemplateDemo() { const generatedId = useId().replace(/:/g, ""); const searchRef = useRef(null); const [query, setQuery] = useState(""); const [resultType, setResultType] = useState("all"); const [faqCategory, setFaqCategory] = useState("all"); const [openQuestion, setOpenQuestion] = useState(""); const visibleArticles = useMemo(() => { const normalized = query.trim().toLocaleLowerCase(); return HELP_ARTICLES.filter((article) => { const matchesType = resultType === "all" || article.type === resultType; const matchesQuery = !normalized || `${article.title} ${article.description} ${article.typeLabel}` .toLocaleLowerCase() .includes(normalized); return matchesType && matchesQuery; }); }, [query, resultType]); const filters: readonly TidalSearchFilter[] = [ { id: "all", label: "All", accessibleLabel: "Show all help results", count: HELP_ARTICLES.length, }, { id: "guide", label: "Guides", accessibleLabel: "Show guides", count: HELP_ARTICLES.filter((article) => article.type === "guide").length, }, { id: "policy", label: "Policies", accessibleLabel: "Show policies", count: HELP_ARTICLES.filter((article) => article.type === "policy") .length, }, ]; const searchResults: readonly TidalSearchResult[] = visibleArticles.map( (article) => ({ id: article.id, title: article.title, description: article.description, typeLabel: article.typeLabel, meta: article.time, action: { kind: "link", href: `#help-article-${generatedId}-${article.id}`, accessibleLabel: `Open ${article.title}`, }, }), ); const groups: readonly TidalSearchResultGroup[] = searchResults.length ? [ { id: "help-results", title: "Guides and policies", accessibleLabel: `${searchResults.length} matching help results`, count: searchResults.length, results: searchResults, }, ] : []; const actions: readonly TidalHelpCenterAction[] = [ { id: "browse", kind: "link", href: `#help-browse-${generatedId}`, label: "Browse guides", description: "Search the supplied local library.", emphasis: "primary", }, { id: "contact", kind: "link", href: `#help-contact-${generatedId}`, label: "Contact options", description: "Review this sample boundary.", }, ]; function resetResults() { setQuery(""); setResultType("all"); searchRef.current?.focus({ preventScroll: true }); } return (
setResultType(filter.id as ResultType), groups, resultCount: searchResults.length, resultCountLabel: (count) => `${count} ${count === 1 ? "help result" : "help results"}`, emptyTitle: "No matching help notes", emptyDescription: "Clear the current query and type to restore the supplied library.", emptyAction: { label: "Show all help", accessibleLabel: "Clear help search and show every result", onAction: resetResults, }, }} faq={{ id: `help-faq-${generatedId}`, title: "Common questions", eyebrow: null, description: "Open an answer from the supplied workspace and file topics.", groups: FAQ_GROUPS, value: openQuestion, onValueChange: setOpenQuestion, category: { value: faqCategory, allId: "all", label: "FAQ topics", options: [ { id: "all", label: "All topics" }, { id: "workspace", label: "Workspace" }, { id: "files", label: "Files" }, ], onValueChange: (value) => { setFaqCategory(value); setOpenQuestion(""); }, }, reset: { label: "Reset questions", onReset: () => { setFaqCategory("all"); setOpenQuestion(""); }, }, summaryHint: "Choose a topic, then open a supplied answer.", }} footer="Sample help content. Search, filters, links, and answers stay in this preview." />
{HELP_ARTICLES.map((article) => (
{article.typeLabel}

{article.title}

{article.body}

))}
); } export default function AgentExample() { return (
); }