"use client"; import "./components/ui/tidal.css"; import { useMemo, useState } from "react"; import { TidalDonutChart, type TidalDonutSegment } from "./components/ui/donut-chart"; import "./components/ui/donut-chart.css"; const tidalExampleStyles = ".tidal-scope .donut-chart-demo {\n container: donut-chart-demo / inline-size;\n display: grid;\n gap: 14px;\n width: 100%;\n max-width: 720px;\n min-width: 0;\n margin-inline: auto;\n}\n\n.tidal-scope .donut-chart-demo-footer {\n display: flex;\n min-width: 0;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n\n.tidal-scope .donut-chart-demo-footer p {\n min-width: 0;\n margin: 0;\n color: var(--t-muted);\n font-size: 11px;\n line-height: 1.45;\n overflow-wrap: anywhere;\n}\n\n.tidal-scope .donut-chart-demo-footer button {\n flex: none;\n min-width: 96px;\n min-height: 44px;\n padding: 0 15px;\n color: var(--t-ink);\n background: var(--t-surface);\n border: 1px solid var(--t-border);\n border-radius: var(--t-radius-control);\n font: inherit;\n font-size: 12px;\n font-weight: 650;\n cursor: pointer;\n transition:\n color 140ms,\n background-color 140ms,\n transform 140ms var(--t-ease-out);\n}\n\n.tidal-scope .donut-chart-demo-footer button:hover:not(:disabled) {\n color: var(--t-surface);\n background: var(--t-ink);\n border-color: var(--t-ink);\n}\n\n.tidal-scope .donut-chart-demo-footer button:active:not(:disabled) {\n transform: scale(0.98);\n}\n\n.tidal-scope .donut-chart-demo-footer button:disabled {\n opacity: 0.42;\n cursor: not-allowed;\n}\n\n@container donut-chart-demo (max-width: 360px) {\n .tidal-scope .donut-chart-demo-footer {\n align-items: stretch;\n flex-direction: column;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tidal-scope .donut-chart-demo-footer button {\n transition: none;\n }\n}\n\n.tidal-scope .donut-chart-demo-note {\n margin: 0;\n color: var(--t-muted);\n font-size: 11px;\n line-height: 1.45;\n}"; const SEGMENTS: readonly TidalDonutSegment[] = [ { id: "research", label: "Research", value: 12, displayValue: "12 h", description: "Project notes and background research.", }, { id: "design", label: "Design", value: 9, displayValue: "9 h", description: "Interface design and prototyping.", }, { id: "writing", label: "Writing", value: 6, displayValue: "6 h", description: "Documentation and release notes.", }, { id: "review", label: "Review", value: 4, displayValue: "4 h", description: "Quality checks and feedback.", }, { id: "handoff", label: "Handoff", value: 0.75, displayValue: "45 min", description: "Delivery notes and handoff.", }, ]; export function DonutChartDemo() { const [activeId, setActiveId] = useState("research"); const [hiddenIds, setHiddenIds] = useState([]); const [status, setStatus] = useState("Research selected: 12 h."); const visibleTotal = useMemo( () => SEGMENTS.filter((segment) => !hiddenIds.includes(segment.id)).reduce( (sum, segment) => sum + segment.value, 0, ), [hiddenIds], ); return (
{ setActiveId(segment.id); setStatus(`${segment.label} selected: ${segment.displayValue}.`); }} hiddenIds={hiddenIds} onHiddenChange={(nextHiddenIds, changedSegment) => { setHiddenIds(nextHiddenIds); const nextVisible = SEGMENTS.find( (segment) => segment.value > 0 && !nextHiddenIds.includes(segment.id), ); if (nextHiddenIds.includes(activeId) && nextVisible) { setActiveId(nextVisible.id); } else if (!nextVisible) { setActiveId(""); } else if (!nextHiddenIds.includes(changedSegment.id)) { setActiveId(changedSegment.id); } setStatus( `${changedSegment.label} ${nextHiddenIds.includes(changedSegment.id) ? "hidden" : "shown"}.`, ); }} />

{status}

Sample data. Changes stay in this preview.

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