This document covers all the playground components available for building interactive learning and development experiences.
| Component | Location | Purpose |
|---|---|---|
| FullStackPlayground | src/components/FullStackPlayground/ |
Complete dApp builder |
| InteractiveCodePlayground | src/components/CodePlayground/ |
Tutorial code runner |
| Playground components | src/components/Playground/ |
Multi-file editors with preview |
| LivePreview | src/components/Playground/ |
Sandboxed iframe preview |
Location: src/components/FullStackPlayground/FullStackPlayground.tsx
Access: lyra.works/fullstack-demo
A complete full-stack dApp development environment combining:
- Smart contract code
- Frontend HTML/CSS/JavaScript
- Live preview
- Console output
interface FullStackPlaygroundProps {
title: string;
description: string;
files: PlaygroundFile[];
scope?: Record<string, any>;
previewStyles?: string;
}
interface PlaygroundFile {
id: string;
name: string;
language: string;
content: string;
}- Multi-file tabs: Switch between contract and frontend files
- Monaco Editor: Full code editing experience
- Live preview: Renders HTML/CSS/JS in real-time
- Console panel: Shows logs, errors, warnings
- Layout options: Editor only, preview only, or split view
- Reset button: Restore original code
- Download: Export all files
import { FullStackPlayground } from '@/components/FullStackPlayground';
<FullStackPlayground
title="Token Dashboard"
description="A simple ERC20 token dashboard"
files={[
{
id: 'contract',
name: 'Token.sol',
language: 'solidity',
content: solidityCode
},
{
id: 'html',
name: 'index.html',
language: 'html',
content: htmlCode
},
{
id: 'css',
name: 'styles.css',
language: 'css',
content: cssCode
},
{
id: 'js',
name: 'app.js',
language: 'javascript',
content: jsCode
}
]}
/>Location: src/components/CodePlayground/InteractiveCodePlayground.tsx
A tab-based code playground for tutorials with optional live preview.
interface InteractiveCodePlaygroundProps {
title: string;
description: string;
tabs: CodeTab[];
tutorial?: TutorialStep[];
challenges?: Challenge[];
livePreview?: boolean;
previewComponent?: React.ReactNode;
onRun?: (code: string, language: string) => Promise<void>;
}
interface CodeTab {
id: string;
label: string;
language: string;
defaultCode: string;
}- Multiple code tabs: Switch between different files/languages
- Tutorial mode: Step-by-step guidance
- Challenges: Built-in coding challenges
- Live preview: Optional preview component
- Run button: Execute code with custom handler
- Copy button: Copy current code
Location: src/components/Playground/LivePreview.tsx
A sandboxed iframe for rendering HTML/CSS/JavaScript with security.
- Sandboxed execution: Safe iframe isolation
- Responsive viewports: Mobile, tablet, desktop presets
- Auto-refresh: Updates on code change
- Full-screen mode: Expand preview
- Open in new tab: Test in full browser
- Console capture: Logs appear in parent
interface LivePreviewProps {
html?: string;
css?: string;
javascript?: string;
title?: string;
allowFullscreen?: boolean;
}<LivePreview
html={htmlCode}
css={cssCode}
javascript={jsCode}
title="My Preview"
allowFullscreen={true}
/>Location: src/components/Playground/FullStackPlayground.tsx
Similar to the main FullStackPlayground but with additional features:
- Contract deployment simulation
- Contract function interaction
- State management
- Console with deployment logs
- Viewport size controls
interface FullStackPlaygroundProps {
title: string;
description: string;
difficulty: 'beginner' | 'intermediate' | 'advanced';
files: CodeFile[];
contractFunctions?: ContractFunction[];
initialState?: Record<string, any>;
onDeploy?: () => Promise<void>;
}Location: src/pages/InteractiveLearningPlayground.tsx
Access: lyra.works/learn
The main learning page with guided tutorials.
- Tutorial browser
- Progress tracking
- Interactive examples
- Step-by-step guidance
- Challenge mode
Location: src/components/ExampleWithPlayground.tsx
Wrapper component that adds a code playground to any example.
interface ExampleWithPlaygroundProps {
children: React.ReactNode;
title: string;
description: string;
contractCode: string;
contractName?: string;
difficulty?: 'beginner' | 'intermediate' | 'advanced';
tags?: string[];
}- Content + Code: Shows explanation alongside editable code
- Syntax highlighting: Monaco editor
- Link to sandbox: "Open in Sandbox" button
- Difficulty badges: Visual difficulty indicator
- Tags: Categorization
ExamplePage
└── ExampleWithPlayground
└── Monaco Editor
└── Contract Code
FullStackDemoPage
└── FullStackPlayground
├── File Tabs
├── Monaco Editor
├── LivePreview (iframe)
└── Console Panel
TutorialPage
└── InteractiveCodePlayground
├── Code Tabs
├── Monaco Editor
├── Tutorial Steps
└── Challenges
SandboxPage
├── WebSandbox
│ ├── File Tree
│ ├── Monaco Editor
│ └── LivePreview
└── SoliditySandbox
├── File Tree
├── Monaco Editor
└── Contract Panel
InteractiveSandbox (Legacy)
├── File Tree
├── Monaco Editor
├── Contract Panel
├── AI Assistant
└── Innovation Features
├── AI Whisperer
├── Time Machine
├── Exploit Lab
├── Collaborative Arena
├── Neural Gas Oracle
└── Cross-Chain Weaver
| Feature | Playgrounds | Sandboxes |
|---|---|---|
| Purpose | Learning & tutorials | Full development |
| Complexity | Simpler | Feature-rich |
| File management | Limited | Full file tree |
| Deployment | Simulated | Real networks |
| AI features | None | AI Assistant |
| Use case | Demos, examples | Building dApps |
| Scenario | Use This |
|---|---|
| Teaching a concept | InteractiveCodePlayground |
| Showing a complete dApp | FullStackPlayground |
| Embedding in tutorials | ExampleWithPlayground |
| Full development | WebSandbox or SoliditySandbox |
| Learning security | InteractiveSandbox + Exploit Lab |
| Quick prototyping | ContractPlayground |
import { useState } from 'react';
import Editor from '@monaco-editor/react';
export default function MyPlayground() {
const [code, setCode] = useState('// Your code here');
const [output, setOutput] = useState('');
const runCode = async () => {
// Execute code logic
setOutput('Executed!');
};
return (
<div className="flex h-screen">
{/* Editor */}
<div className="w-1/2">
<Editor
height="100%"
language="solidity"
value={code}
onChange={(value) => setCode(value || '')}
theme="vs-dark"
/>
</div>
{/* Output */}
<div className="w-1/2 bg-gray-900 p-4">
<button onClick={runCode}>Run</button>
<pre>{output}</pre>
</div>
</div>
);
}- IDE_GUIDE.md - Full IDE documentation
- SANDBOX_GUIDE.md - Sandbox-specific features
- INNOVATION_LAB.md - Experimental AI features
- src/components/Playground/README.md - Component-level docs