import "./components/ui/tidal.css"; import { useId, useMemo, useRef, useState } from "react"; import "./components/ui/code-editor.css"; import { TidalCodeEditor, type TidalCodeEditorDiagnostic } from "./components/ui/code-editor"; const tidalExampleStyles = ".tidal-scope .tidal-code-editor-demo {\n display: grid;\n width: min(100%, 720px);\n min-width: 0;\n margin: 0 auto;\n gap: 14px;\n}\n\n.tidal-scope .tidal-code-editor-demo button {\n min-height: 44px;\n max-width: 100%;\n padding: 0 14px;\n border: 1px solid var(--t-border);\n border-radius: var(--t-radius-control);\n color: var(--t-ink);\n background: var(--t-surface);\n font: inherit;\n font-size: 12px;\n font-weight: 650;\n overflow-wrap: anywhere;\n cursor: pointer;\n transition:\n color 140ms,\n background 140ms,\n border-color 140ms,\n transform 140ms;\n}\n\n.tidal-scope .tidal-code-editor-demo-footer {\n display: grid;\n grid-template-columns: max-content minmax(0, 1fr);\n align-items: center;\n gap: 10px 14px;\n min-width: 0;\n}\n\n.tidal-scope .tidal-code-editor-demo-footer > button {\n color: var(--t-surface);\n background: var(--t-ink);\n border-color: var(--t-ink);\n}\n\n.tidal-scope .tidal-code-editor-demo output,\n.tidal-scope .tidal-code-editor-demo-note {\n min-width: 0;\n margin: 0;\n color: var(--t-muted);\n font-size: 11px;\n line-height: 1.6;\n overflow-wrap: anywhere;\n}\n\n@media (hover: hover) and (pointer: fine) {\n .tidal-scope .tidal-code-editor-demo button:hover {\n border-color: var(--t-ink);\n transform: translateY(-1px);\n }\n\n .tidal-scope .tidal-code-editor-demo-footer > button:hover {\n color: var(--t-ink);\n background: var(--t-surface);\n }\n}\n\n.tidal-scope .tidal-code-editor-demo button:active {\n transform: translateY(1px);\n}\n\n.tidal-scope .tidal-code-editor-demo button:focus-visible {\n outline: 2px solid var(--t-ring);\n outline-offset: 3px;\n}\n\n@media (max-width: 420px) {\n .tidal-scope .tidal-code-editor-demo-footer {\n grid-template-columns: minmax(0, 1fr);\n }\n\n .tidal-scope .tidal-code-editor-demo-footer > button {\n width: 100%;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tidal-scope .tidal-code-editor-demo button {\n transition: none;\n }\n\n .tidal-scope .tidal-code-editor-demo button:hover,\n .tidal-scope .tidal-code-editor-demo button:active {\n transform: none;\n }\n}"; const SAMPLE = `{ // Keep refresh intervals explicit. "refreshMinutes": 15, "compactNavigation": true }`; export function CodeEditorDemo() { const formId = useId().replace(/[^a-zA-Z0-9_-]/g, "-"); const [value, setValue] = useState(SAMPLE); const [status, setStatus] = useState("One local diagnostic is supplied."); const source = useRef(null); const diagnostics = useMemo( () => value.includes("//") ? [ { id: "json-comment", line: 2, column: 3, message: "JSON does not allow comments.", }, ] : [], [value], ); return (
{ event.preventDefault(); const submitted = String( new FormData(event.currentTarget).get("config") ?? "", ); setStatus( diagnostics.length ? "Fix the supplied diagnostic before local review." : `Reviewed ${submitted.length} local characters.`, ); }} > { setValue(next); setStatus("Local draft updated."); }} diagnostics={diagnostics} textareaRef={source} textareaProps={{ name: "config", required: true, rows: 8, "aria-label": "Environment config source", }} tabBehavior="indent" actions={ } description="Tab inserts two spaces. Shift+Tab removes one indentation level." />
{status}

Fictional sample. Editing and review stay in this page; no code runs or saves.

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