import { useState } from 'react'; interface ElementInfo { tagName: string; className: string; id: string; textContent: string; styles: Record; // Changed from CSSStyleDeclaration rect: { x: number; y: number; width: number; height: number; top: number; left: number; }; } interface InspectorPanelProps { selectedElement: ElementInfo | null; isVisible: boolean; onClose: () => void; } export const InspectorPanel = ({ selectedElement, isVisible, onClose }: InspectorPanelProps) => { const [activeTab, setActiveTab] = useState<'styles' | 'computed' | 'box'>('styles'); if (!isVisible || !selectedElement) { return null; } const getRelevantStyles = (styles: Record) => { const relevantProps = [ 'display', 'position', 'width', 'height', 'margin', 'padding', 'border', 'background', 'color', 'font-size', 'font-family', 'text-align', 'flex-direction', 'justify-content', 'align-items', ]; return relevantProps.reduce( (acc, prop) => { const value = styles[prop]; if (value) { acc[prop] = value; } return acc; }, {} as Record, ); }; return (
{/* Header */}

Element Inspector

{/* Element Info */}
{selectedElement.tagName.toLowerCase()} {selectedElement.id && #{selectedElement.id}} {selectedElement.className && ( .{selectedElement.className.split(' ')[0]} )}
{selectedElement.textContent && (
"{selectedElement.textContent}"
)}
{/* Tabs */}
{(['styles', 'computed', 'box'] as const).map((tab) => ( ))}
{/* Content */}
{activeTab === 'styles' && (
{Object.entries(getRelevantStyles(selectedElement.styles)).map(([prop, value]) => (
{prop}: {value}
))}
)} {activeTab === 'box' && (
Width: {Math.round(selectedElement.rect.width)}px
Height: {Math.round(selectedElement.rect.height)}px
Top: {Math.round(selectedElement.rect.top)}px
Left: {Math.round(selectedElement.rect.left)}px
)}
); };