"use client"; import "./components/ui/tidal.css"; import { useId, useState, type MouseEvent } from "react"; import { TidalWorkspaceSwitcher, type TidalWorkspaceOption } from "./components/ui/workspace-switcher"; import "./components/ui/workspace-switcher.css"; import "./components/ui/combobox.css"; const tidalExampleStyles = ".workspace-switcher-demo {\n width: 100%;\n max-width: 660px;\n min-width: 0;\n display: grid;\n gap: 14px;\n padding: 18px;\n}\n\n.workspace-switcher-demo > .tidal-workspace-switcher {\n width: 100%;\n}\n\n.workspace-switcher-demo-actions {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n\n.workspace-switcher-demo-actions button {\n min-width: 44px;\n min-height: 44px;\n padding: 9px 12px;\n border: 1px solid var(--t-ink);\n border-radius: 10px;\n color: var(--t-surface);\n background: var(--t-ink);\n font: inherit;\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n transition:\n color 160ms var(--t-ease-out),\n background 160ms var(--t-ease-out),\n transform 140ms var(--t-ease-out);\n}\n\n.workspace-switcher-demo-actions button + button {\n color: var(--t-ink);\n background: var(--t-surface);\n border-color: var(--t-border);\n}\n\n.workspace-switcher-demo-actions button:hover {\n transform: translateY(-1px);\n}\n\n.workspace-switcher-demo-actions button:active {\n transform: scale(0.985);\n}\n\n.workspace-switcher-demo-actions button:focus-visible {\n outline: 2px solid var(--t-accent);\n outline-offset: 2px;\n}\n\n.workspace-switcher-demo-destination {\n min-width: 0;\n padding: 14px;\n border: 1px solid var(--t-border);\n border-radius: 12px;\n background: var(--t-subtle);\n}\n\n.workspace-switcher-demo-destination[hidden] {\n display: none;\n}\n\n.workspace-switcher-demo-destination h3,\n.workspace-switcher-demo-destination p,\n.workspace-switcher-demo > [role=\"status\"],\n.workspace-switcher-demo-note {\n margin: 0;\n overflow-wrap: anywhere;\n}\n\n.workspace-switcher-demo-destination h3 {\n font-size: 13px;\n line-height: 1.3;\n}\n\n.workspace-switcher-demo-destination p,\n.workspace-switcher-demo > [role=\"status\"],\n.workspace-switcher-demo-note {\n color: var(--t-muted);\n font-size: 11px;\n line-height: 1.5;\n}\n\n.workspace-switcher-demo-destination p {\n margin-top: 4px;\n}\n\n.workspace-switcher-demo-note {\n padding-top: 12px;\n border-top: 1px solid var(--t-border);\n}\n\n@container preview-canvas (max-width: 390px) {\n .workspace-switcher-demo {\n padding: 10px;\n }\n\n .workspace-switcher-demo-actions {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n\n@media (max-width: 480px) {\n .workspace-switcher-demo {\n padding: 10px;\n }\n\n .workspace-switcher-demo-actions {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .workspace-switcher-demo-actions button {\n transition: none;\n }\n\n .workspace-switcher-demo-actions button:hover,\n .workspace-switcher-demo-actions button:active {\n transform: none;\n }\n}"; const WORKSPACES: readonly TidalWorkspaceOption[] = [ { id: "north-star", name: "North Star", role: "Owner", status: "Active", description: "Product planning and launch work", searchTerms: ["product", "launch"], }, { id: "field-notes", name: "Field Notes", role: "Editor", status: "Active", description: "Research briefs and customer notes", searchTerms: ["research", "customer"], }, { id: "studio-lab", name: "Studio Lab", role: "Viewer", status: "Review", description: "Design experiments awaiting review", searchTerms: ["design", "review"], }, { id: "archive-2025", name: "2025 Archive", role: "Viewer", status: "Unavailable", description: "Archived sample workspace", unavailable: true, }, ]; function plainPrimary(event: MouseEvent) { return ( event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey ); } export function WorkspaceSwitcherDemo() { const uid = useId().replace(/:/g, ""); const formId = `workspace-demo-form-${uid}`; const createId = `workspace-create-${uid}`; const manageId = `workspace-manage-${uid}`; const [query, setQuery] = useState(""); const [open, setOpen] = useState(false); const [highlighted, setHighlighted] = useState(); const [activeId, setActiveId] = useState("north-star"); const [destination, setDestination] = useState<"create" | "manage" | null>( null, ); const [status, setStatus] = useState("North Star is active."); const active = WORKSPACES.find((workspace) => workspace.id === activeId); return (
{ event.preventDefault(); const data = new FormData(event.currentTarget); setStatus( `Prepared ${String(data.get("workspace") ?? "none")} locally.`, ); }} /> { setQuery(nextQuery); setHighlighted(undefined); }} onOpenChange={setOpen} onHighlightedWorkspaceChange={setHighlighted} onWorkspaceChange={(workspace) => { setActiveId(workspace.id); setQuery(""); setOpen(false); setStatus(`${workspace.name} is active in this preview.`); }} name="workspace" form={formId} createHref={`#${createId}`} createLabel="Create workspace" createLinkProps={{ onClick: (event: import("react").MouseEvent) => { if (plainPrimary(event)) { setDestination("create"); setStatus("Create workspace details opened locally."); } }, }} manageHref={`#${manageId}`} manageLabel="Manage workspace" manageDisabled={!active} manageLinkProps={{ onClick: (event: import("react").MouseEvent) => { if (plainPrimary(event)) { setDestination("manage"); setStatus("Manage workspace details opened locally."); } }, }} />

{status}

Sample workspaces. Changes stay in this preview.

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