"use client"; import "./components/ui/tidal.css"; import { useId, useLayoutEffect, useRef, useState } from "react"; import { TidalOrderSummary, type TidalOrderSummaryItem } from "./components/ui/order-summary"; import "./components/ui/order-summary.css"; const tidalExampleStyles = ".order-summary-demo,\n.order-summary-demo * {\n box-sizing: border-box;\n}\n\n.order-summary-demo {\n width: 100%;\n min-width: 0;\n container: order-demo / inline-size;\n}\n\n.order-summary-demo-details {\n margin-top: 12px;\n padding: 14px 16px;\n border: 1px solid var(--t-border);\n border-radius: 12px;\n background: var(--t-subtle);\n color: var(--t-muted);\n font-size: 11px;\n line-height: 1.5;\n}\n\n.order-summary-demo-details > span {\n color: var(--t-ink);\n font-size: 11px;\n font-weight: 720;\n letter-spacing: 0.08em;\n text-transform: uppercase;\n}\n\n.order-summary-demo-details p {\n margin: 5px 0 0;\n overflow-wrap: anywhere;\n}\n\n.order-summary-demo-complete {\n display: grid;\n width: 100%;\n min-height: 280px;\n place-items: center;\n align-content: center;\n gap: 12px;\n padding: 30px;\n border: 1px solid var(--t-border);\n border-radius: 22px;\n background: var(--t-surface);\n color: var(--t-ink);\n text-align: center;\n box-shadow: 0 30px 74px -56px #0000008f;\n animation: order-demo-complete 420ms var(--t-ease-out) both;\n}\n\n.order-summary-demo-complete > span {\n display: grid;\n width: 56px;\n height: 56px;\n place-items: center;\n border-radius: 50%;\n background: var(--t-ink);\n color: var(--t-surface);\n font-size: 22px;\n}\n\n.order-summary-demo-complete h3 {\n max-width: 16ch;\n margin: 4px 0 0;\n font-size: clamp(25px, 8cqi, 40px);\n font-weight: 560;\n letter-spacing: -0.05em;\n line-height: 1;\n overflow-wrap: anywhere;\n}\n\n.order-summary-demo-complete h3:focus-visible {\n outline: 2px solid var(--t-accent);\n outline-offset: 5px;\n}\n\n.order-summary-demo-complete p {\n max-width: 42ch;\n margin: 0;\n color: var(--t-muted);\n font-size: 11px;\n line-height: 1.55;\n overflow-wrap: anywhere;\n}\n\n.order-summary-demo-complete button {\n min-width: 44px;\n min-height: 44px;\n padding: 10px 14px;\n border: 1px solid var(--t-ink);\n border-radius: 10px;\n background: var(--t-ink);\n color: var(--t-surface);\n cursor: pointer;\n font: inherit;\n font-size: 11px;\n font-weight: 690;\n}\n\n.order-summary-demo-complete button:focus-visible {\n outline: 2px solid var(--t-accent);\n outline-offset: 3px;\n}\n\n@container order-demo (max-width: 420px) {\n .order-summary-demo-complete {\n padding: 22px 16px;\n }\n\n .order-summary-demo-complete button {\n width: 100%;\n font-size: 16px;\n }\n}\n\n@media (hover: none), (pointer: coarse) {\n .order-summary-demo-complete button {\n font-size: 16px;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .order-summary-demo-complete {\n animation: none;\n }\n}\n\n@keyframes order-demo-complete {\n from {\n opacity: 0;\n transform: translateY(12px);\n }\n}"; const SAMPLE_ITEMS: readonly TidalOrderSummaryItem[] = [ { id: "workspace", name: "Workspace plan", description: "One month in this local sample.", unitPrice: "$29.00 each", quantity: "1", amount: "$29.00", media: W, }, { id: "contributors", name: "Contributor seats", description: "Two fictional sample seats.", unitPrice: "$8.00 each", quantity: "2", amount: "$16.00", media: 2, }, { id: "archive", name: "Archive add-on", description: "Sample document retention display.", unitPrice: "$8.00 each", quantity: "1", amount: "$8.00", media: A, }, ]; export function OrderSummaryDemo() { const instanceId = useId().replace(/:/g, ""); const detailsId = `order-sample-details-${instanceId}`; const [creditApplied, setCreditApplied] = useState(false); const [reviewed, setReviewed] = useState(false); const reviewButtonRef = useRef(null); const completeHeadingRef = useRef(null); const shouldFocusComplete = useRef(false); const shouldFocusReview = useRef(false); useLayoutEffect(() => { if (!reviewed || !shouldFocusComplete.current) return; shouldFocusComplete.current = false; completeHeadingRef.current?.focus({ preventScroll: true }); }, [reviewed]); useLayoutEffect(() => { if (reviewed || !shouldFocusReview.current) return; shouldFocusReview.current = false; reviewButtonRef.current?.focus({ preventScroll: true }); }, [reviewed]); if (reviewed) { return ( ✓ Sample order ready for review The preview total is {creditApplied ? "$48.00" : "$53.00"}. No payment or order was submitted. { shouldFocusReview.current = true; setReviewed(false); }} > Adjust sample order ); } return ( item.id === "workspace" ? { ...item, href: `#${detailsId}` } : item, )} rows={[ { id: "subtotal", label: "Subtotal", value: "$53.00" }, { id: "credit", label: "Sample credit", detail: creditApplied ? "Applied locally" : "Not applied", value: creditApplied ? "−$5.00" : "$0.00", emphasis: creditApplied ? "strong" : "normal", }, ]} totalLabel="Sample total" totalValue={creditApplied ? "$48.00" : "$53.00"} notice="Fictional USD display values. This preview cannot charge, order, or store payment details." actions={[ { kind: "button", id: "credit", label: creditApplied ? "Remove sample credit" : "Apply sample credit", buttonProps: { "aria-pressed": creditApplied }, onAction: () => setCreditApplied((current) => !current), }, { kind: "link", id: "details", label: "Review item details", href: `#${detailsId}`, }, { kind: "button", id: "review", label: "Review sample order", emphasis: "primary", buttonRef: reviewButtonRef, onAction: () => { shouldFocusComplete.current = true; setReviewed(true); }, }, ]} /> ); } export default function AgentExample() { return ( ); }
The preview total is {creditApplied ? "$48.00" : "$53.00"}. No payment or order was submitted.