'use client' import presenceExample from './examples/presence-example' import chatExample from './examples/chat-example' import todoExample from './examples/todo-example' import collaborativeEditorExample from './examples/collaborative-editor-example' import whiteboardExample from './examples/whiteboard-example' import ticTacToeExample from './examples/tic-tac-toe-example' import emojiPickerExample from './examples/emoji-picker-example' import platformer3DExample from './examples/platformer-3d-example' import iframeAnnotationExample from './examples/iframe-annotation-example' import logViewerExample from './examples/log-viewer-example' import formPresenceExample from './examples/form-presence-example' import cursorTrackingExample from './examples/cursor-tracking-example' import { Tabs, TabsList, TabsTrigger } from 'ui' import { Users, MessageSquare, CheckSquare, Edit, PenTool, Hash, Smile, Gamepad2, StickyNote, FileText, ClipboardList, MousePointer, } from 'lucide-react' import { useState, useCallback } from 'react' import ExampleLayout from './example-layout' // Define the list of examples for easier navigation const EXAMPLES = [ { value: 'presence', label: 'Presence', icon: Users, props: presenceExample, }, { value: 'chat', label: 'Chat', icon: MessageSquare, props: chatExample, }, { value: 'todo', label: 'Todo List', icon: CheckSquare, props: todoExample, }, { value: 'editor', label: 'Editor', icon: Edit, props: collaborativeEditorExample, }, { value: 'formPresence', label: 'Form', icon: ClipboardList, props: formPresenceExample, }, { value: 'cursorTracking', label: 'Cursor', icon: MousePointer, props: cursorTrackingExample, }, { value: 'whiteboard', label: 'Whiteboard', icon: PenTool, props: whiteboardExample, }, { value: 'tictactoe', label: 'XO', icon: Hash, props: ticTacToeExample, }, { value: 'emoji', label: 'Reactions', icon: Smile, props: emojiPickerExample, }, { value: 'platformer', label: 'Platformer', icon: Gamepad2, props: platformer3DExample, }, { value: 'annotation', label: 'Annotation', icon: StickyNote, props: iframeAnnotationExample, }, { value: 'logs', label: 'Logs', icon: FileText, props: logViewerExample, }, ] export default function RealtimeShowcase() { // Use numeric index for active tab const [activeTabIndex, setActiveTabIndex] = useState(0) const handleTabChange = (value: string) => { const index = EXAMPLES.findIndex((ex) => ex.value === value) if (index !== -1) { setActiveTabIndex(index) } } const handleNext = useCallback(() => { if (activeTabIndex < EXAMPLES.length - 1) { setActiveTabIndex(activeTabIndex + 1) } }, [activeTabIndex]) const handlePrevious = useCallback(() => { if (activeTabIndex > 0) { setActiveTabIndex(activeTabIndex - 1) } }, [activeTabIndex]) // Get the current example from the index const currentExample = EXAMPLES[activeTabIndex] return (