-
Theme Toggle Button in the header (next to the editor toggle)
- Sun icon for light mode, Moon icon for dark mode
- Smooth theme switching with CSS transitions
-
Dual Color Schemes:
- Dark Theme (Default): Deep purples, blues, and grays
- Light Theme: Clean whites, subtle grays, and warmer accents
-
Theme Persistence:
- User's theme preference is saved to localStorage
- Theme persists across browser sessions
- Key:
visualizer-theme
-
Comprehensive Theming:
- All components updated for both themes
- Syntax highlighting colors adjusted for readability
- Buttons, panels, and borders automatically adapt
- Light theme hover states optimized (softer shadows)
src/index.css- Added:root.lighttheme variables and light-specific stylessrc/App.jsx- Added theme state, toggle function, and localStorage integration
- Click the sun/moon icon in the header to toggle themes
- Theme preference is automatically saved
-
Type Inference Engine (
src/utils/typeInference.js):- Parses JavaScript/TypeScript code using Babel
- Detects type annotations from:
- Variable declarations (
const x: string) - Function parameters (
function foo(x: number)) - Function return types (
function foo(): string) - TypeScript interfaces, type aliases, and enums
- Variable declarations (
- Infers types from value assignments
- Handles complex types (unions, intersections, generics, arrays)
-
Type Annotation Display:
- Hover Detection: Type info appears when hovering over code lines
- Badge Format: Shows
symbol: typein a styled tooltip - Visual Indicators: Cyan-colored badges with blue type values
- Smooth Animation: Type tooltips fade in/out smoothly
-
Error Detection:
- Detects parse errors and syntax issues
- Shows warning indicator (
⚠️ ) on problematic lines - Error tooltip displays full error message on hover
- Red-tinted indicators for easy identification
-
TypeScript Support:
- Full support for TypeScript syntax
- Recognizes:
- Primitive types (string, number, boolean, etc.)
- Complex types (Array, Promise, Record, etc.)
- Generic types
- Union and intersection types
- Type aliases and interfaces
- Enums and decorators
src/utils/typeInference.js- Type inference and error detection engine
src/components/CodeViewer.jsx- Added type tooltip rendering and hover detectionsrc/index.css- Added styles for type annotations and error indicators
- View Types: Hover over any line of code to see type information
- See Errors: Watch for warning indicators on lines with parse errors
- Hover for Details: Hover over error indicators to read the error message
const name: string = "Alice"; // Hover: shows "name: string"
const age: number = 30; // Hover: shows "age: number"
function greet(msg: string): void // Hover: shows return type "→ void"- Added theme toggle button (Sun/Moon icon)
- Button positioned before editor toggle
- Consistent styling with existing controls
- Type badges appear in tooltips on hover
- Error indicators show on line numbers
- Line numbers now support inline elements
- Smooth animations for type/error display
--bg-base: #ffffff
--bg-surface: #f8f8fa
--text-primary: #1a1a1a
--accent-cyan: #0891b2
--accent-blue: #5c5ce6- Click the sun/moon icon in the header
- See the entire UI switch between dark and light modes
- Refresh the page - theme preference is remembered
- Run sample code (especially TypeScript samples)
- Hover over lines with variable declarations
- See type information in a tooltip
- Check error lines for warning indicators
- TS: Types & Interfaces - Shows interface type annotations
- TS: Enum & Generics - Shows enum and generic type information
- TS: Type Alias & Assertion - Shows type aliases and unions
Both features use standard web APIs:
- CSS custom properties (widely supported)
- localStorage API
- Babel parser (included in project dependencies)
- React hooks (useState, useEffect, useRef)
Possible improvements:
- Show variable values in type annotations during execution
- Add type error checking with a linter
- Display method signatures on hover
- Show inheritance chains for classes
- Add type inference for return values from assignments
- Theme auto-detection from OS settings