import React, { useEffect, useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { HiCube, HiCodeBracket, HiEye, HiSparkles, HiCog, HiBeaker, HiDocumentText, HiPlus } from 'react-icons/hi2'; import Typography from '../components/ui/Typography'; import { Button } from '../components/ui/Button'; import { useBlockTesterStore, useBlocks, useActiveBlockIndex, useCurrentBlock, useBlockStates } from '../stores/blockTesterStore'; import { cn } from '../lib/utils'; import BlockEditor from '../components/tools/block-tester/editors/BlockEditor'; import BlockPreview from '../components/tools/block-tester/preview/BlockPreviewDirect'; import DevTools from '../components/tools/block-tester/panels/DevTools'; import { ScrollArea } from '../components/ui/scroll-area'; import BlockTabs from '../components/tools/block-tester/tabs/BlockTabs'; import { useBlockTesterKeyboard } from '../hooks/useBlockTesterKeyboard'; const BlockTesterPage: React.FC = () => { const { createBlock, duplicateBlock, closeBlock, switchToBlock, reorderBlocks, validateActiveBlock, errors, previewMode, isLoading } = useBlockTesterStore(); const blocks = useBlocks(); const activeBlockIndex = useActiveBlockIndex(); const currentBlock = useCurrentBlock(); const blockStates = useBlockStates(); const [showDevTools, setShowDevTools] = useState(false); const [activePanel, setActivePanel] = useState<'editor' | 'preview'>('editor'); useEffect(() => { if (blocks.length === 0) { createBlock(); } }, []); const validation = validateActiveBlock(); const hasErrors = validation.errors.length > 0; const hasWarnings = validation.warnings.length > 0; useBlockTesterKeyboard({ onNextTab: () => { if (blocks.length > 1) { const nextIndex = (activeBlockIndex + 1) % blocks.length; switchToBlock(nextIndex); } }, onPrevTab: () => { if (blocks.length > 1) { const prevIndex = activeBlockIndex === 0 ? blocks.length - 1 : activeBlockIndex - 1; switchToBlock(prevIndex); } }, onCloseTab: () => { if (blocks.length > 1 && activeBlockIndex >= 0) { closeBlock(activeBlockIndex); } }, onNewTab: () => { createBlock(); }, onDuplicateTab: () => { if (activeBlockIndex >= 0) { duplicateBlock(activeBlockIndex); } }, onSwitchToTab: (index: number) => { switchToBlock(index); }, totalTabs: blocks.length, isEnabled: true }); return (
Block Tester
{/* Block tabs - show only when blocks exist */} {blocks.length > 0 && ( )}
{currentBlock ? ( ) : (
Create your first block Click "New Block" to start building
)}
{currentBlock ? ( ) : (
No preview available
)}
{showDevTools && (
)}
); }; export default BlockTesterPage;