import "./components/ui/tidal.css"; import { useEffect, useLayoutEffect, useRef, useState } from "react"; import { ArrowUpRight, Check, RotateCcw } from "lucide-react"; import { TidalDatePicker, TidalDateDigits, tidalParseDate, tidalFormatDate } from "./components/ui/date-picker"; import { TidalButton } from "./components/ui/tidal-button"; import "./components/ui/date-picker.css"; const tidalExampleStyles = ".tidal-scope .date-picker-specimen {\n width: 100%;\n max-width: 720px;\n padding: 28px;\n border: 1px solid var(--t-border);\n border-radius: var(--t-radius-card);\n background: var(--t-surface);\n box-shadow:\n 0 2px 3px #00000004,\n 0 18px 35px -30px #00000040;\n}\n.tidal-scope .date-picker-specimen > h3 {\n font-size: 29px;\n font-weight: 500;\n line-height: 1.15;\n letter-spacing: -1.1px;\n margin: 15px 0 26px;\n}\n.tidal-scope .date-picker-specimen > h3 em {\n font:\n italic 37px/1.15 \"Instrument Serif\",\n Georgia,\n serif;\n letter-spacing: -0.8px;\n}\n.tidal-scope .date-demo-stage {\n padding: 7px;\n margin: 0 -7px;\n overflow: hidden;\n transition: height 420ms var(--t-ease-out);\n}\n.tidal-scope .date-demo-content {\n display: flow-root;\n}\n.tidal-scope .date-demo-layout {\n display: grid;\n grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);\n gap: 28px;\n align-items: center;\n}\n.tidal-scope .date-demo-layout form {\n min-width: 0;\n}\n.tidal-scope .date-demo-form-caption {\n display: block;\n font-size: 11px;\n letter-spacing: 1.3px;\n color: var(--t-muted);\n margin-bottom: 24px;\n}\n.tidal-scope .date-demo-paper {\n position: relative;\n min-width: 0;\n border: 1px solid var(--t-ink);\n border-radius: 12px;\n background: var(--t-ink);\n color: var(--t-surface);\n padding: 20px;\n box-shadow:\n 0 14px 20px -15px #00000050,\n inset 0 1px 0 #ffffff12;\n overflow: hidden;\n animation: date-paper-enter 620ms var(--t-ease-out) both;\n}\n.tidal-scope .date-demo-paper:before,\n.tidal-scope .date-demo-paper:after {\n content: \"\";\n position: absolute;\n top: -6px;\n width: 13px;\n height: 13px;\n border: 1px solid #80808060;\n background: var(--t-surface);\n border-radius: 50%;\n}\n.tidal-scope .date-demo-paper:before {\n left: 20px;\n}\n.tidal-scope .date-demo-paper:after {\n right: 20px;\n}\n.tidal-scope .date-demo-paper-header {\n display: flex;\n justify-content: space-between;\n gap: 8px;\n font-size: 11px;\n letter-spacing: 1.3px;\n opacity: 0.65;\n padding-top: 3px;\n margin-bottom: 26px;\n}\n.tidal-scope .date-demo-paper-month {\n font-size: 11px;\n letter-spacing: 0.9px;\n text-transform: uppercase;\n animation: date-month-enter 280ms var(--t-ease-out) both;\n}\n.tidal-scope .date-demo-paper-number {\n font-size: 94px;\n line-height: 1.1;\n font-weight: 500;\n letter-spacing: -5px;\n margin: 10px 0 14px;\n}\n.tidal-scope .date-demo-paper time {\n display: block;\n max-width: 240px;\n font-size: 11px;\n line-height: 1.5;\n opacity: 0.8;\n}\n.tidal-scope .date-demo-week {\n display: grid;\n position: relative;\n grid-template-columns: repeat(7, minmax(0, 1fr));\n isolation: isolate;\n font-size: 11px;\n height: 30px;\n margin-top: 20px;\n border-top: 1px solid #80808055;\n padding-top: 8px;\n}\n.tidal-scope .date-demo-week > span:not(.date-demo-week-marker) {\n display: flex;\n justify-content: center;\n align-items: center;\n color: inherit;\n opacity: 0.5;\n transition:\n opacity 220ms,\n color 220ms;\n z-index: 1;\n}\n.tidal-scope .date-demo-week > span[data-active] {\n color: var(--t-ink);\n opacity: 1;\n}\n.tidal-scope .date-demo-week-marker {\n position: absolute;\n width: calc(100% / 7);\n height: 22px;\n left: 0;\n top: 8px;\n border-radius: 5px;\n background: var(--t-surface);\n transition: transform 420ms var(--t-ease-out);\n}\n.tidal-scope .date-demo-paper > p {\n font-size: 11px;\n line-height: 1.6;\n margin: 12px 0 0;\n color: inherit;\n opacity: 0.65;\n}\n.tidal-scope .date-demo-paper-empty {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n min-height: 205px;\n gap: 17px;\n text-align: center;\n}\n.tidal-scope .date-demo-paper-empty > svg {\n opacity: 0.5;\n}\n.tidal-scope .date-demo-paper-empty p {\n color: inherit;\n font-size: 13px;\n line-height: 1.6;\n}\n.tidal-scope .date-demo-actions {\n display: flex;\n gap: 8px;\n margin-top: 22px;\n}\n.tidal-scope .date-demo-actions .tidal-button {\n flex: 1;\n min-width: 0;\n padding: 0 9px;\n font-size: 11px;\n outline-offset: -5px;\n}\n.tidal-scope .date-demo-actions .tidal-button:focus-visible {\n outline-color: currentColor;\n}\n.tidal-scope .date-demo-status {\n display: block;\n font-size: 11px;\n color: var(--t-muted);\n line-height: 1.5;\n margin-top: 10px;\n}\n.tidal-scope .date-demo-note {\n font-size: 11px;\n color: var(--t-muted);\n line-height: 1.65;\n margin: 22px 0 0;\n}\n.tidal-scope .date-demo-complete {\n text-align: center;\n padding: 16px 5px 22px;\n animation: date-paper-enter 420ms var(--t-ease-out) both;\n}\n.tidal-scope .date-demo-complete > span {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 44px;\n height: 44px;\n background: var(--t-ink);\n color: var(--t-surface);\n border-radius: 50%;\n margin: 0 auto 15px;\n}\n.tidal-scope .date-demo-complete h4 {\n font-size: 22px;\n font-weight: 500;\n letter-spacing: -0.7px;\n outline-offset: -5px;\n}\n.tidal-scope .date-demo-complete p {\n font-size: 11px;\n color: var(--t-muted);\n margin-top: 9px;\n}\n.tidal-scope .date-picker-specimen[data-phase=\"set\"] .date-demo-layout {\n grid-template-columns: 1fr;\n}\n.tidal-scope .date-picker-specimen[data-phase=\"set\"] .date-demo-paper {\n max-width: 290px;\n width: 100%;\n margin-inline: auto;\n}\n.tidal-scope .date-demo-saved-actions {\n justify-content: center;\n}\n.tidal-scope .date-demo-saved-actions .tidal-button {\n flex: 0 1 auto;\n padding: 0 16px;\n}\n.tidal-scope .date-demo-saved-actions .tidal-button:last-child {\n width: 44px;\n padding: 0;\n}\n@keyframes date-paper-enter {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n@keyframes date-month-enter {\n from {\n opacity: 0;\n transform: translateY(3px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n@media (max-width: 600px) {\n .tidal-scope .date-picker-specimen {\n padding: 16px;\n }\n .tidal-scope .date-picker-specimen > h3 {\n font-size: 25px;\n margin: 12px 0 16px;\n }\n .tidal-scope .date-picker-specimen > h3 em {\n font-size: 32px;\n }\n .tidal-scope .date-demo-layout {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n .tidal-scope .date-demo-form-caption {\n display: none;\n }\n .tidal-scope .date-demo-paper {\n padding: 16px;\n }\n .tidal-scope .date-demo-paper-header {\n margin-bottom: 10px;\n }\n .tidal-scope .date-demo-paper-number {\n font-size: 68px;\n margin: 7px 0 10px;\n }\n .tidal-scope .date-demo-paper-empty {\n min-height: 176px;\n }\n .tidal-scope .date-demo-actions {\n margin-top: 14px;\n }\n .tidal-scope .date-demo-week {\n margin-top: 12px;\n }\n .tidal-scope .date-demo-paper > p {\n margin-top: 8px;\n }\n .tidal-scope .date-demo-note {\n font-size: 11px;\n margin-top: 14px;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .tidal-scope .date-picker-specimen * {\n animation: none !important;\n transition: none !important;\n }\n .tidal-scope .date-demo-paper,\n .tidal-scope .date-demo-complete,\n .tidal-scope .date-demo-paper-month {\n transform: none;\n }\n}"; const sampleToday = "2026-10-14"; function unavailable(iso: string) { const day = tidalParseDate(iso)?.getUTCDay(); return day === 0 || day === 6 || iso === "2026-11-26"; } export function DatePickerDemo() { const [date, setDate] = useState("2026-11-12"), [error, setError] = useState(""); const [phase, setPhase] = useState<"editing" | "setting" | "set">("editing"), [height, setHeight] = useState(); const input = useRef(null), title = useRef(null), content = useRef(null), restore = useRef(false), timer = useRef | undefined>(undefined); const focusOwner = useRef(null); const parsed = tidalParseDate(date), valid = Boolean( parsed && date! >= sampleToday && date! <= "2026-12-31" && !unavailable(date!), ); const days = parsed ? Math.round( (parsed.getTime() - tidalParseDate(sampleToday)!.getTime()) / 86400000, ) : 0; const weekday = parsed ? (parsed.getUTCDay() + 6) % 7 : 0; useEffect(() => () => clearTimeout(timer.current), []); useLayoutEffect(() => { const active = document.activeElement; const canMoveFocus = active === document.body || active === focusOwner.current; if (phase === "set" && canMoveFocus) { title.current?.focus({ preventScroll: true }); focusOwner.current = null; } else if (phase === "editing" && restore.current) { restore.current = false; if (canMoveFocus) input.current?.focus({ preventScroll: true }); focusOwner.current = null; } }, [phase]); useLayoutEffect(() => { const node = content.current; if (!node) return; const measure = () => { const css = getComputedStyle(node.parentElement!); setHeight( node.offsetHeight + Number.parseFloat(css.paddingTop) + Number.parseFloat(css.paddingBottom), ); }; measure(); const ro = new ResizeObserver(measure); ro.observe(node); return () => ro.disconnect(); }, []); function edit() { clearTimeout(timer.current); focusOwner.current = document.activeElement instanceof HTMLElement ? document.activeElement : null; setError(""); restore.current = true; setPhase("editing"); if (phase === "editing") { restore.current = false; input.current?.focus({ preventScroll: true }); } } function reset() { setDate("2026-11-12"); edit(); } return (
{phase === "set" ? (

A day to begin.

Kept in this sample. No launch or appointment was scheduled.

) : null}
{phase !== "set" ? (
{ e.preventDefault(); if (!valid) { setError( "Choose an available weekday in this sample range.", ); input.current?.focus({ preventScroll: true }); return; } focusOwner.current = (e.nativeEvent as SubmitEvent).submitter instanceof HTMLElement ? (e.nativeEvent as SubmitEvent).submitter : document.activeElement instanceof HTMLElement ? document.activeElement : null; setPhase("setting"); timer.current = setTimeout(() => setPhase("set"), 550); }} > THE FIRST LITTLE MILESTONE { setDate(next); setError(""); }} name="launch-date" min={sampleToday} max="2026-12-31" today={sampleToday} isDateDisabled={unavailable} required disabled={phase === "setting"} description="Fictional weekdays only. November 26 is held in this sample." error={error} />
{phase === "setting" ? "Cancel sample" : "Reset sample"} {phase === "setting" ? "Setting date" : "Set sample date"} {phase === "editing" ? : null}
{phase === "setting" ? ( Setting this local sample… ) : null} ) : null}
THE RELEASE DATE D / 029
{parsed ? ( <>

{days} days from the sample today.

) : (

Pick the day.
We’ll put it here.

)}
{phase === "set" ? (
Adjust sample
) : null}

Fictional availability. Nothing is scheduled, sent or stored.

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