import * as React from 'react'; import { Button } from './ui/button'; import { HelpCircle, X } from 'lucide-react'; import { ICONS, SCN_SYMBOLS } from 'scn-ts-core'; import { Card, CardContent, CardHeader, CardTitle } from './ui/card'; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "./ui/accordion" const symbolIconGroups: Record = { 'Class or Component': ['class', 'react_component'], 'Interface or Trait': ['interface', 'rust_trait'], 'Function or Method': ['function', 'method', 'styled_component'], 'Variable or Property': ['variable', 'property'], Enum: ['enum'], 'Type Alias': ['type_alias'], 'JSX Element': ['jsx_element'], 'CSS Selector': ['css_class'], }; const symbolIcons = Object.entries(symbolIconGroups).flatMap(([description, iconKeys]) => iconKeys.map(key => ({ symbol: ICONS[key], description })) ); const legendSections = [ { title: 'Prefixes', items: [ { symbol: SCN_SYMBOLS.FILE_PREFIX, description: 'File path' }, { symbol: SCN_SYMBOLS.EXPORTED_PREFIX, description: 'Exported symbol' }, { symbol: SCN_SYMBOLS.PRIVATE_PREFIX, description: 'Private/unexported symbol' }, ], }, { title: 'Symbol Icons', items: Array.from(new Map(symbolIcons.map(item => [item.symbol, item])).values()), }, { title: 'Relationships', items: [ { symbol: SCN_SYMBOLS.OUTGOING_ARROW, description: 'Outgoing dependency' }, { symbol: SCN_SYMBOLS.INCOMING_ARROW, description: 'Incoming dependency' }, ], }, { title: 'Modifiers & Tags', items: [ { symbol: SCN_SYMBOLS.ASYNC, description: 'Async' }, { symbol: SCN_SYMBOLS.THROWS, description: 'Throws error' }, { symbol: SCN_SYMBOLS.PURE, description: 'Pure (no side-effects)' }, { symbol: SCN_SYMBOLS.TAG_STYLED, description: 'Styled component' }, { symbol: SCN_SYMBOLS.TAG_DYNAMIC, description: 'Dynamic import' }, { symbol: SCN_SYMBOLS.TAG_GENERATED, description: 'Generated file' }, ], }, ]; const LegendItem: React.FC<{ symbol: string; description: string }> = ({ symbol, description }) => (
{symbol} {description}
); export const Legend: React.FC = () => { const [isOpen, setIsOpen] = React.useState(false); if (!isOpen) { return (
); } return (
Legend s.title)} className="w-full"> {legendSections.map(({ title, items }) => ( {title}
{items.map(({ symbol, description }) => symbol && )}
))}
); };