"use client"; import "./components/ui/tidal.css"; import { useState } from "react"; import { TidalSettingsPageTemplate, type TidalSettingsPageGeneralConfig, type TidalSettingsPageNotificationsConfig } from "./components/ui/settings-page-template"; import "./components/ui/settings-page-template.css"; import "./components/ui/settings-panel.css"; import "./components/ui/notification-preferences.css"; import "./components/ui/color-picker.css"; const tidalExampleStyles = ".settings-page-template-demo {\n width: 100%;\n min-width: 0;\n}\n\n.settings-page-template-demo .tidal-settings-page-footer p {\n margin: 0;\n}"; type Density = "comfortable" | "compact"; interface GeneralValues { density: Density; weeklySummary: boolean; } const INITIAL_GENERAL: GeneralValues = { density: "comfortable", weeklySummary: true, }; const INITIAL_NOTIFICATIONS: Readonly> = { "assignment:in-app": true, "assignment:email": false, "review:in-app": true, "review:email": true, }; const CHANNELS = [ { id: "in-app", label: "In app", accessibleLabel: "In-app sample" }, { id: "email", label: "Email", accessibleLabel: "Email sample" }, ] as const; const PRESETS = [ { id: "ink", value: "#171717", label: "Ink", accessibleLabel: "Use ink" }, { id: "graphite", value: "#444444", label: "Graphite", accessibleLabel: "Use graphite", }, { id: "stone", value: "#737373", label: "Stone", accessibleLabel: "Use stone", }, ] as const; export function SettingsPageTemplateDemo() { const [general, setGeneral] = useState(INITIAL_GENERAL); const [appliedGeneral, setAppliedGeneral] = useState(INITIAL_GENERAL); const [notifications, setNotifications] = useState>({ ...INITIAL_NOTIFICATIONS, }); const [savedNotifications, setSavedNotifications] = useState< Record >({ ...INITIAL_NOTIFICATIONS }); const [color, setColor] = useState("#171717"); const [status, setStatus] = useState("Sample settings are ready."); const generalConfig: TidalSettingsPageGeneralConfig = { title: "General", description: "Choose how this fictional workspace preview is arranged.", groups: [ { id: "workspace-view", title: "Workspace view", fields: [ { id: "density", kind: "select", name: "density", label: "Navigation density", value: general.density, options: [ { value: "comfortable", label: "Comfortable" }, { value: "compact", label: "Compact" }, ], onValueChange: (value) => { setGeneral((current) => ({ ...current, density: value as Density, })); setStatus("General draft changed locally."); }, }, { id: "weekly-summary", kind: "toggle", name: "weeklySummary", label: "Weekly summary", description: "Include a summary in this sample configuration.", checked: general.weeklySummary, onCheckedChange: (checked) => { setGeneral((current) => ({ ...current, weeklySummary: checked, })); setStatus("General draft changed locally."); }, }, ], }, ], onSubmit: (event: import("react").FormEvent) => { event.preventDefault(); setAppliedGeneral(general); setStatus("General sample applied to the summary below."); }, onReset: () => { setGeneral(INITIAL_GENERAL); setAppliedGeneral(INITIAL_GENERAL); setStatus("General sample reset."); }, applyLabel: "Apply general sample", resetLabel: "Reset general sample", }; const notificationConfig: TidalSettingsPageNotificationsConfig = { title: "Notifications", description: "Choose where fictional project updates appear.", channels: CHANNELS, groups: [ { id: "project-updates", title: "Project updates", preferences: [ { id: "assignment", label: "Task assigned", accessibleLabel: "Task assigned", controls: CHANNELS.map((channel) => ({ channelId: channel.id, checked: notifications[`assignment:${channel.id}`] ?? false, })), }, { id: "review", label: "Review requested", accessibleLabel: "Review requested", controls: CHANNELS.map((channel) => ({ channelId: channel.id, checked: notifications[`review:${channel.id}`] ?? false, })), }, ], }, ], onPreferenceChange: (preference, channel, checked) => { setNotifications((current) => ({ ...current, [`${preference.id}:${channel.id}`]: checked, })); setStatus("Notification draft changed locally."); }, onSave: (event) => { event.preventDefault(); setSavedNotifications({ ...notifications }); setStatus("Notification sample applied to the summary below."); }, resetAction: { label: "Reset notification sample", onAction: () => { setNotifications({ ...INITIAL_NOTIFICATIONS }); setSavedNotifications({ ...INITIAL_NOTIFICATIONS }); setStatus("Notification sample reset."); }, }, labels: { save: "Apply notification sample" }, }; const enabledDeliveryCount = Object.values(savedNotifications).filter(Boolean).length; return (
{ setColor(value); setStatus("Appearance sample changed locally."); }, resetAction: { label: "Reset appearance sample", accessibleLabel: "Reset appearance sample to ink", onAction: () => { setColor("#171717"); setStatus("Appearance sample reset to ink."); }, }, }} footer={

{status} Applied view: {appliedGeneral.density}, weekly summary{" "} {appliedGeneral.weeklySummary ? "on" : "off"}; notification channels on: {enabledDeliveryCount}; color: {color}. Fictional local sample only.

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