"use client"; import "./components/ui/tidal.css"; import { CalendarDays, Check, ChevronRight, FileText, MessageSquareText, RefreshCw, Unplug, Workflow } from "lucide-react"; import { useEffect, useId, useMemo, useRef, useState } from "react"; import { TidalIntegrationCards, type TidalIntegrationItem, type TidalIntegrationState } from "./components/ui/integration-cards"; import "./components/ui/integration-cards.css"; const tidalExampleStyles = ".tidal-scope .integration-cards-demo,\n.tidal-scope .integration-cards-demo * {\n box-sizing: border-box;\n}\n\n.tidal-scope .integration-cards-demo {\n display: grid;\n width: 100%;\n min-width: 0;\n grid-template-columns: minmax(0, 1fr);\n gap: 16px;\n padding: 16px;\n color: var(--t-ink);\n background: var(--t-subtle);\n border: 1px solid var(--t-border);\n border-radius: 22px;\n container: integration-demo / inline-size;\n}\n\n.tidal-scope .integration-cards-demo-main {\n min-width: 0;\n padding: 16px;\n background: var(--t-surface);\n border: 1px solid var(--t-border);\n border-radius: 16px;\n}\n\n.tidal-scope .integration-cards-demo .tidal-integration-footer > button {\n display: inline-flex;\n min-width: 44px;\n min-height: 44px;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 8px 12px;\n color: var(--t-ink);\n background: var(--t-surface);\n border: 1px solid var(--t-border);\n border-radius: 10px;\n font: inherit;\n font-size: 11px;\n font-weight: 650;\n cursor: pointer;\n}\n\n.tidal-scope .integration-cards-demo .tidal-integration-footer > button svg {\n width: 15px;\n height: 15px;\n}\n\n.tidal-scope .integration-cards-demo .tidal-integration-footer > button:hover {\n border-color: var(--t-ink);\n}\n\n.tidal-scope\n .integration-cards-demo\n .tidal-integration-footer\n > button:focus-visible,\n.tidal-scope .integration-cards-demo-details h3:focus-visible {\n outline: 2px solid var(--t-accent);\n outline-offset: 3px;\n}\n\n.tidal-scope .integration-cards-demo-details {\n display: grid;\n min-width: 0;\n grid-template-columns: minmax(150px, 0.7fr) minmax(180px, 1fr) minmax(\n 220px,\n 1fr\n );\n align-items: center;\n gap: 16px;\n margin-top: 14px;\n padding: 16px;\n color: var(--t-surface);\n background: var(--t-ink);\n border-radius: 14px;\n}\n\n.tidal-scope .integration-cards-demo-details span,\n.tidal-scope .integration-cards-demo-details dt {\n color: #bdbdbd;\n font-size: 11px;\n font-weight: 680;\n letter-spacing: 0.09em;\n line-height: 1.4;\n text-transform: uppercase;\n}\n\n.tidal-scope .integration-cards-demo-details h3 {\n margin: 5px 0 0;\n color: inherit;\n font-size: 16px;\n line-height: 1.2;\n overflow-wrap: anywhere;\n}\n\n.tidal-scope .integration-cards-demo-details p {\n margin: 0;\n color: #d0d0d0;\n font-size: 11px;\n line-height: 1.55;\n overflow-wrap: anywhere;\n}\n\n.tidal-scope .integration-cards-demo-details dl {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 12px;\n margin: 0;\n}\n\n.tidal-scope .integration-cards-demo-details dl > div,\n.tidal-scope .integration-cards-demo-details dd {\n min-width: 0;\n}\n\n.tidal-scope .integration-cards-demo-details dd {\n margin: 4px 0 0;\n color: var(--t-surface);\n font-size: 11px;\n font-weight: 620;\n line-height: 1.4;\n overflow-wrap: anywhere;\n}\n\n.tidal-scope .integration-cards-demo-status {\n min-height: 18px;\n margin: 10px 4px 0;\n color: var(--t-muted);\n font-size: 11px;\n line-height: 1.5;\n overflow-wrap: anywhere;\n}\n\n@container integration-demo (max-width: 760px) {\n .tidal-scope .integration-cards-demo {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n\n@container integration-demo (max-width: 560px) {\n .tidal-scope .integration-cards-demo {\n padding: 8px;\n border-radius: 16px;\n }\n\n .tidal-scope .integration-cards-demo-main {\n padding: 12px;\n border-radius: 13px;\n }\n\n .tidal-scope .integration-cards-demo-details {\n grid-template-columns: minmax(0, 1fr);\n gap: 10px;\n padding: 14px;\n }\n\n .tidal-scope .integration-cards-demo-details dl {\n padding-top: 10px;\n border-top: 1px solid #ffffff2e;\n }\n\n .tidal-scope .integration-cards-demo .tidal-integration-footer {\n align-items: flex-start;\n flex-direction: column;\n }\n}\n\n@container integration-demo (max-width: 390px) {\n .tidal-scope .integration-cards-demo-main {\n padding: 9px;\n }\n}\n\n@media (pointer: coarse) {\n .tidal-scope .integration-cards-demo :is(input, select, textarea) {\n font-size: 16px;\n }\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .tidal-scope .integration-cards-demo-details {\n animation: integration-details-in 300ms var(--t-ease-out) both;\n }\n}\n\n@keyframes integration-details-in {\n from {\n opacity: 0;\n transform: translateY(6px);\n }\n to {\n opacity: 1;\n transform: none;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tidal-scope .integration-cards-demo-details {\n animation: none;\n }\n\n .tidal-scope .integration-cards-demo .tidal-integration-footer > button {\n transition: none;\n }\n}"; type IntegrationId = "schedule" | "files" | "notes" | "relay"; type FilterId = "all" | TidalIntegrationState; interface SampleIntegration { id: IntegrationId; name: string; description: string; state: TidalIntegrationState; } const initialIntegrations: readonly SampleIntegration[] = [ { id: "schedule", name: "Schedule bridge", description: "Preview how sample project dates could be grouped in one place.", state: "connected", }, { id: "files", name: "File handoff", description: "Stage sample project documents for a local review flow.", state: "available", }, { id: "notes", name: "Team notes", description: "Review a sample channel that needs a delivery choice.", state: "attention", }, { id: "relay", name: "Relay rules", description: "Preview a local rule after a sample task is completed.", state: "available", }, ] as const; const iconById = { schedule: , files: , notes: , relay: , } satisfies Record; const settingsById = { schedule: [ { id: "range", label: "Range", value: "Next 14 sample days" }, { id: "direction", label: "Direction", value: "Two-way preview" }, ], files: [ { id: "folder", label: "Folder", value: "Sample project files" }, { id: "access", label: "Access", value: "Preview only" }, ], notes: [ { id: "channel", label: "Channel", value: "Review notes" }, { id: "delivery", label: "Delivery", value: "Choose manually" }, ], relay: [ { id: "trigger", label: "Trigger", value: "Task completed" }, { id: "result", label: "Result", value: "Local status only" }, ], } satisfies Record< IntegrationId, readonly { id: string; label: string; value: string }[] >; const detailById = { schedule: "Shows a 14-day sample range and a two-way preview setting.", files: "Keeps fictional project documents inside this browser preview.", notes: "Waits for a sample delivery choice before its state is cleared.", relay: "Changes only the local card state after a sample task event.", } satisfies Record; function stateLabel(state: TidalIntegrationState) { if (state === "connected") return "Connected in sample"; if (state === "attention") return "Review sample"; return "Available"; } export function IntegrationCardsDemo() { const generatedId = useId().replace(/:/g, ""); const detailsId = `integration-sample-details-${generatedId}`; const [integrations, setIntegrations] = useState(initialIntegrations); const [filter, setFilter] = useState("all"); const [selectedDetails, setSelectedDetails] = useState("schedule"); const [message, setMessage] = useState( "This preview is local. No service or account was contacted.", ); const detailsHeadingRef = useRef(null); const focusFrameRef = useRef(null); useEffect( () => () => { if (focusFrameRef.current !== null) { cancelAnimationFrame(focusFrameRef.current); } }, [], ); const counts = useMemo( () => ({ all: integrations.length, connected: integrations.filter((item) => item.state === "connected") .length, available: integrations.filter((item) => item.state === "available") .length, attention: integrations.filter((item) => item.state === "attention") .length, }), [integrations], ); const visibleIntegrations = useMemo( () => filter === "all" ? integrations : integrations.filter((item) => item.state === filter), [filter, integrations], ); function updateState(id: IntegrationId, nextState: TidalIntegrationState) { const item = integrations.find((entry) => entry.id === id); if (!item) return; setIntegrations((current) => current.map((entry) => entry.id === id ? { ...entry, state: nextState } : entry, ), ); if (filter !== "all" && filter !== nextState) setFilter("all"); setMessage( `${item.name} is now ${stateLabel(nextState).toLowerCase()}. This changed sample state only.`, ); } function showDetails(id: IntegrationId) { setSelectedDetails(id); setMessage( `Showing local details for ${integrations.find((item) => item.id === id)?.name ?? "the sample"}.`, ); if (focusFrameRef.current !== null) { cancelAnimationFrame(focusFrameRef.current); } focusFrameRef.current = requestAnimationFrame(() => { focusFrameRef.current = null; detailsHeadingRef.current?.focus({ preventScroll: true }); }); } const cards = useMemo( () => visibleIntegrations.map((integration) => { const isConnected = integration.state === "connected"; const needsReview = integration.state === "attention"; return { id: integration.id, name: integration.name, description: integration.description, icon: iconById[integration.id], status: { state: integration.state, label: stateLabel(integration.state), }, settings: settingsById[integration.id], action: { kind: "button", label: isConnected ? "Disconnect sample" : needsReview ? "Mark sample reviewed" : "Connect sample", icon: isConnected ? : , onAction: () => updateState( integration.id, isConnected ? "available" : "connected", ), }, secondaryAction: { kind: "button", label: "View details", icon: , buttonProps: { "aria-controls": detailsId }, onAction: () => showDetails(integration.id), }, footer: "Local preview data", }; }), [detailsId, visibleIntegrations], ); const filters = (["all", "connected", "available", "attention"] as const).map( (id) => ({ id, label: id === "all" ? "All" : id === "connected" ? "Connected" : id === "available" ? "Available" : "Review", count: counts[id], }), ); const selected = integrations.find((item) => item.id === selectedDetails)!; function selectFilter(nextFilter: string) { const next = nextFilter as FilterId; const nextVisible = next === "all" ? integrations : integrations.filter((item) => item.state === next); setFilter(next); if ( nextVisible.length > 0 && !nextVisible.some((item) => item.id === selectedDetails) ) { setSelectedDetails(nextVisible[0].id); } setMessage( next === "all" ? "Showing all four local samples." : nextVisible.length ? `Showing ${nextVisible.length} ${next} local ${nextVisible.length === 1 ? "sample" : "samples"}.` : `No local samples are ${next}.`, ); } function resetSample() { if (focusFrameRef.current !== null) { cancelAnimationFrame(focusFrameRef.current); focusFrameRef.current = null; } setIntegrations(initialIntegrations); setFilter("all"); setSelectedDetails("schedule"); setMessage("Sample reset. No service or account was contacted."); } return (
Fictional sample data } />
Selected preview

{selected.name}

{detailById[selected.id]}

{settingsById[selected.id].map((setting) => (
{setting.label}
{setting.value}
))}

{message}

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