import "./components/ui/tidal.css"; import { useState, type MouseEvent } from "react"; import { TidalFooterConsent, type TidalFooterConsentCategory, type TidalFooterConsentLink, type TidalFooterConsentState } from "./components/ui/footer-consent"; import "./components/ui/footer-consent.css"; import "./components/ui/toggle-switch.css"; const tidalExampleStyles = ".tidal-scope .footer-pilot-07-demo {\n inline-size: 100%;\n min-inline-size: 0;\n}"; const categories: readonly TidalFooterConsentCategory[] = [ { id: "essential", label: "Essential services", description: "Needed to keep the site working.", required: true, }, { id: "analytics", label: "Analytics", description: "Help us understand which pages are useful.", }, ]; const policyLinks: readonly TidalFooterConsentLink[] = [ { id: "privacy", label: "Privacy policy", href: "#consent-privacy" }, { id: "cookies", label: "Cookie details", href: "#consent-cookies" }, ]; function handlePreviewClick( label: string, setStatus: (status: string) => void, ) { return (event: MouseEvent) => { if ( event.defaultPrevented || event.button !== 0 || (event.detail !== 0 && event.detail !== 1) || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.currentTarget.target ) { return; } event.preventDefault(); setStatus(`${label} selected in this local preview.`); }; } export function FooterConsentDemo() { const [values, setValues] = useState>>({ essential: true, analytics: false, }); const [saveState, setSaveState] = useState("idle"); const [status, setStatus] = useState( "No preference result has been submitted.", ); const localPolicyLinks = policyLinks.map((link) => ({ ...link, onClick: handlePreviewClick(String(link.label), setStatus), })); return (
TidalUI workspace} heading="Privacy preferences." description="Choose which optional services you allow." categories={categories} values={values} onCategoryChange={(id, checked) => { setValues((current) => ({ ...current, [id]: checked })); setSaveState("dirty"); setStatus( `${id} is now ${checked ? "enabled" : "disabled"} locally.`, ); }} policyLinks={localPolicyLinks} onSubmit={(event) => { event.preventDefault(); setSaveState("saved"); setStatus( "Local preview only. The consumer callback received the supplied values; no cookies or storage were changed.", ); }} onRejectOptional={() => { setValues((current) => ({ ...current, analytics: false })); setSaveState("saved"); setStatus( "Optional choices were proposed as disabled in this local preview; the consumer owns persistence.", ); }} saveState={saveState} status={status} legal={Local preview. No cookies or storage are changed.} />
); } export default function AgentExample() { return (
); }