From 78e61dea383b338de009472256b1318a809edad5 Mon Sep 17 00:00:00 2001 From: waleed Date: Fri, 12 Dec 2025 21:03:28 -0800 Subject: [PATCH] feat(ui): added component playground & fixed training modal --- apps/sim/app/playground/page.tsx | 566 ++++++++++++ .../w/[workflowId]/components/index.ts | 1 - .../components/terminal/terminal.tsx | 129 +++ .../training-controls/training-controls.tsx | 40 - .../training-floating-button.tsx | 78 -- .../training-controls/training-modal.tsx | 866 +++++++++--------- .../[workspaceId]/w/[workflowId]/workflow.tsx | 10 +- apps/sim/lib/core/config/env.ts | 4 +- 8 files changed, 1155 insertions(+), 539 deletions(-) create mode 100644 apps/sim/app/playground/page.tsx delete mode 100644 apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/training-controls/training-controls.tsx delete mode 100644 apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/training-controls/training-floating-button.tsx diff --git a/apps/sim/app/playground/page.tsx b/apps/sim/app/playground/page.tsx new file mode 100644 index 0000000000..7a3804211a --- /dev/null +++ b/apps/sim/app/playground/page.tsx @@ -0,0 +1,566 @@ +'use client' + +import { useState } from 'react' +import { ArrowLeft, Bell, Folder, Key, Settings, User } from 'lucide-react' +import { notFound, useRouter } from 'next/navigation' +import { + Badge, + Breadcrumb, + BubbleChatPreview, + Button, + Card as CardIcon, + ChevronDown, + Code, + Combobox, + Connections, + Copy, + DocumentAttachment, + Duplicate, + Eye, + FolderCode, + FolderPlus, + HexSimple, + Input, + Key as KeyIcon, + Label, + Layout, + Library, + Modal, + ModalBody, + ModalContent, + ModalFooter, + ModalHeader, + ModalTabs, + ModalTabsContent, + ModalTabsList, + ModalTabsTrigger, + ModalTrigger, + MoreHorizontal, + NoWrap, + PanelLeft, + Play, + Popover, + PopoverBackButton, + PopoverContent, + PopoverFolder, + PopoverItem, + PopoverScrollArea, + PopoverSearch, + PopoverSection, + PopoverTrigger, + Redo, + Rocket, + SModal, + SModalContent, + SModalMain, + SModalMainBody, + SModalMainHeader, + SModalSidebar, + SModalSidebarHeader, + SModalSidebarItem, + SModalSidebarSection, + SModalSidebarSectionTitle, + SModalTrigger, + Switch, + Textarea, + Tooltip, + Trash, + Trash2, + Undo, + Wrap, + ZoomIn, + ZoomOut, +} from '@/components/emcn' +import { env, isTruthy } from '@/lib/core/config/env' + +function Section({ title, children }: { title: string; children: React.ReactNode }) { + return ( +
+

+ {title} +

+
{children}
+
+ ) +} + +function VariantRow({ label, children }: { label: string; children: React.ReactNode }) { + return ( +
+ {label} +
{children}
+
+ ) +} + +const SAMPLE_CODE = `function greet(name) { + console.log("Hello, " + name); + return { success: true }; +}` + +const SAMPLE_PYTHON = `def greet(name): + print(f"Hello, {name}") + return {"success": True}` + +const COMBOBOX_OPTIONS = [ + { label: 'Option 1', value: 'opt1' }, + { label: 'Option 2', value: 'opt2' }, + { label: 'Option 3', value: 'opt3' }, +] + +export default function PlaygroundPage() { + const router = useRouter() + const [comboboxValue, setComboboxValue] = useState('') + const [switchValue, setSwitchValue] = useState(false) + const [activeTab, setActiveTab] = useState('profile') + + if (!isTruthy(env.NEXT_PUBLIC_ENABLE_PLAYGROUND)) { + notFound() + } + + return ( + +
+ + + + + Go back + +
+
+

+ EMCN Component Playground +

+

+ All emcn UI components and their variants +

+
+ + {/* Button */} +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + {/* Badge */} +
+ + Default + + + Outline + +
+ + {/* Input */} +
+ + + + + + +
+ + {/* Textarea */} +
+