Skip to content

Commit c11ed63

Browse files
committed
chore: updated documentation for playground"
1 parent f1bc250 commit c11ed63

File tree

3 files changed

+68
-17
lines changed

3 files changed

+68
-17
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# playground_tabs_controller.js
2+
3+
Manages tabbed interface for switching between code editor and file preview.
4+
5+
## Outlets
6+
- `wasm` - PHP WASM runtime for reading files
7+
- `code-editor` - Code editor instance
8+
9+
## Targets
10+
- `tabBar` - Container for tab buttons
11+
- `codeTab` - Code editor tab button
12+
- `previewTab` - Preview tab button
13+
- `previewTabName` - Span showing preview file name
14+
- `codePanel` - Code editor container
15+
- `previewPanel` - Preview content container
16+
- `downloadBtn` - Download button for preview file
17+
18+
## Values
19+
- `activeTab` (String, default: 'code') - Currently active tab ('code' or 'preview')
20+
- `previewFile` (String, default: '') - Path of currently previewed file
21+
22+
## Public Methods
23+
24+
### `switchToCode(event?: Event): void`
25+
Switches to code editor tab.
26+
27+
### `switchToPreview(event?: Event): void`
28+
Switches to preview tab (only if a file is being previewed).
29+
30+
### `openFile(event: Event): Promise<void>`
31+
Opens a file from the workspace in the preview tab.
32+
33+
**Parameters:**
34+
- `event.currentTarget.dataset.filePath` - Path relative to `/workspace/`
35+
36+
Special case: If filePath is `/code.php`, switches to code tab instead of opening preview.
37+
38+
### `openFileFromDropdown(event: Event): void`
39+
Opens a file selected from the mobile dropdown. Resets dropdown selection after opening.
40+
41+
### `closePreview(event?: Event): void`
42+
Closes the preview tab and switches to code tab.
43+
44+
### `downloadPreviewFile(event?: Event): void`
45+
Downloads the currently previewed file to the user's computer.
46+
47+
## Syntax Highlighting
48+
49+
Uses CodeMirror 6 for read-only preview with syntax highlighting:
50+
- `.php`, `.phar` - PHP syntax
51+
- `.json` - JSON syntax
52+
- `.xml` - XML syntax
53+
- Other extensions - Plain text
54+
55+
## File: `playground_tabs_controller.js`

web/landing/docs/playground/playground-workspace.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ Display and navigate the WASM virtual filesystem.
77
- `code-editor` - Code editor
88
- `playground` - Main playground controller
99

10+
## Targets
11+
- `tree` - Container for the file tree (desktop view)
12+
- `dropdown` - Select element for file selection (mobile view)
13+
- `emptyState` - Empty state message when no files
14+
1015
## Public Methods
1116

1217
### `refreshTree(): Promise<void>`
@@ -60,11 +65,6 @@ Returns promise that resolves when tree is rendered for first time.
6065
**Payload:** `{ fileCount: number }`
6166
**Bubbles:** Yes
6267

63-
### `playground-workspace:file-selected`
64-
**Trigger:** User clicks file in tree
65-
**Payload:** `{ path: string, content: string }`
66-
**Bubbles:** Yes
67-
6868
## Value Configuration
6969

7070
- `rootPath` - Root directory to display (default: `/workspace`)
@@ -75,8 +75,9 @@ Returns promise that resolves when tree is rendered for first time.
7575

7676
- Files sorted alphabetically
7777
- Folders displayed before files
78-
- Clicking file previews it via `playground#previewFile()`
79-
- Tree auto-refreshes on filesystem changes
78+
- Clicking file in tree opens it via `playground-tabs#openFile()`
79+
- Selecting file in dropdown (mobile) opens it via `playground-tabs#openFileFromDropdown()`
80+
- Tree and dropdown auto-refresh on filesystem changes
8081
- Shows empty state when no files present
8182

8283
## File: `playground_workspace_controller.js`

web/landing/docs/playground/playground.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Main orchestrator and event hub for the playground.
77
- `code-editor` - Code editor
88
- `turnstile` - CAPTCHA widget
99
- `playground-output` - Output display
10+
- `playground-tabs` - Tab navigation between code editor and file preview
1011

1112
## Public Methods
1213

@@ -22,17 +23,11 @@ Displays loading progress with message and percentage.
2223
### `hideLoading(): void`
2324
Hides loading indicators and shows main UI.
2425

25-
### `previewFile(event: Event): Promise<void>`
26-
Preview file from workspace. Reads file via WASM, applies syntax highlighting with Prism, and displays in preview panel.
26+
### `onActionStarted(): void`
27+
Called when any action button is pressed. Disables action buttons, shows spinner, and switches to code tab.
2728

28-
**Parameters:**
29-
- `event.currentTarget.dataset.filePath` - Path relative to `/workspace/`
30-
31-
### `closeFilePreview(event?: Event): void`
32-
Closes the file preview panel.
33-
34-
### `downloadPreviewFile(event?: Event): void`
35-
Downloads currently previewed file to user's computer.
29+
### `onActionFinished(): void`
30+
Called when action completes. Re-enables action buttons and hides spinner.
3631

3732
## Events Listened
3833

0 commit comments

Comments
 (0)