import { action, computed, NAME, pattern, UI, Writable } from "commonfabric"; // deno-lint-ignore no-empty-interface interface MobileAppDemoInput {} export interface MobileAppDemoOutput { [NAME]: string; [UI]: unknown; } const IOS_HOME_THEME = { borderRadius: "18px", colors: { surface: { light: "rgba(255, 255, 255, 0.72)", dark: "rgba(255, 255, 255, 0.08)", }, surfaceHover: { light: "rgba(255, 255, 255, 0.88)", dark: "rgba(255, 255, 255, 0.14)", }, }, }; type TaskItem = { title: string; detail: string; meta: string; actionLabel: string; actionTone: "blue" | "coral" | "graphite"; section: "Needs action" | "Knock something out"; }; type ShortcutItem = { icon: string; title: string; subtitle: string; }; type ArtifactItem = { title: string; tint: string; }; type TabContent = { heading: string; subtitle?: string; tasks?: TaskItem[]; shortcuts?: ShortcutItem[]; artifacts?: ArtifactItem[]; items?: { title: string; detail: string; meta: string }[]; }; const TASK_SECTIONS: Array<"Needs action" | "Knock something out"> = [ "Needs action", "Knock something out", ]; const HOME_CONTENT: TabContent = { heading: "Good evening.", subtitle: "Last woven just now", tasks: [ { title: "Schedule an appointment with a vet specializing in GI", detail: "Pet care", meta: "Needs action", actionLabel: "Review", actionTone: "blue", section: "Needs action", }, { title: "Prepare slides for all-hands meeting", detail: "Work", meta: "Needs action", actionLabel: "Launch", actionTone: "coral", section: "Needs action", }, { title: "Draft the Pattern implementation for the new home surface", detail: "Fabric", meta: "Ready", actionLabel: "Start", actionTone: "graphite", section: "Knock something out", }, { title: "Triage the latest partner threads before tomorrow morning", detail: "Comms", meta: "Fresh", actionLabel: "Reply", actionTone: "blue", section: "Knock something out", }, ], shortcuts: [ { icon: "✦", title: "Answer", subtitle: "questions" }, { icon: "◎", title: "Create", subtitle: "pattern" }, { icon: "▤", title: "Learn", subtitle: "about Fabric" }, { icon: "◌", title: "Review", subtitle: "activity" }, ], artifacts: [ { title: "Launch brief", tint: "#ece9ff" }, { title: "Roadmap v2", tint: "#dfeaff" }, { title: "Brand draft", tint: "#ffe9df" }, { title: "Workspace map", tint: "#e5f6ef" }, ], }; const tabContent: Record = { home: HOME_CONTENT, search: { heading: "Search", items: [ { title: "Navigation shell feedback", detail: "3 results", meta: "Thread", }, { title: "Pattern deploy notes", detail: "7 results", meta: "Document" }, { title: "Mobile home surface", detail: "12 results", meta: "Project" }, ], }, inbox: { heading: "Inbox", items: [ { title: "Design review moved to Friday", detail: "From: Alex", meta: "2h ago", }, { title: "Pattern deploy notes ready", detail: "From: Sam", meta: "4h ago", }, { title: "New comments from research team", detail: "From: Jordan", meta: "Yesterday", }, { title: "Fabric sync: nav shell feedback", detail: "From: Chris", meta: "Yesterday", }, ], }, profile: { heading: "Profile", items: [ { title: "Edit display name", detail: "Settings", meta: "Account" }, { title: "Notification preferences", detail: "Settings", meta: "Alerts", }, { title: "Connected apps", detail: "2 active", meta: "Integrations" }, ], }, }; function chipColor( tone: "blue" | "coral" | "graphite", ): "primary" | "accent" | "neutral" { if (tone === "blue") { return "primary"; } if (tone === "coral") { return "accent"; } return "neutral"; } export default pattern(() => { const activeTab = new Writable("home"); const sheetOpen = new Writable(false); const toastOpen = new Writable(false); const openSheet = action(() => sheetOpen.set(true)); const closeSheet = action(() => sheetOpen.set(false)); const handleCreate = action(() => { sheetOpen.set(false); toastOpen.set(true); }); const dismissToast = action(() => toastOpen.set(false)); return { [NAME]: "Mobile App Demo", [UI]: ( {computed(() => { const tab = activeTab.get(); const content = tabContent[tab] ?? tabContent.home; const isHome = tab === "home"; if (isHome) { const home = content as typeof HOME_CONTENT; return ( {/* Header */}
{home.heading} {home.subtitle}
{/* Task sections */} {TASK_SECTIONS.map(( section: "Needs action" | "Knock something out", ) => ( {section} {(home.tasks ?? []) .filter((t: TaskItem) => t.section === section) .map((task: TaskItem) => ( {task.title} {task.detail} ))} ))} {/* Shortcuts */} Shortcuts {(home.shortcuts ?? []).map((sc: ShortcutItem) => ( {sc.icon} {sc.title} {sc.subtitle} ))} {/* Artifacts */} Recent artifacts {(home.artifacts ?? []).map(( artifact: ArtifactItem, ) => (
{artifact.title}
))}
); } // Non-home tabs: simple card list const items = content.items ?? []; return ( {content.heading} {items.map(( item: { title: string; detail: string; meta: string }, ) => ( {item.title} {item.detail} {item.meta} ))} ); })} 🏠 🔍 📬 👤
New Task
Cancel Create
Task created. View
), }; });