Skip to content

Commit ed5214a

Browse files
committed
feat: update API docs as per the tabbed bottom panel architecture
1 parent 25908c3 commit ed5214a

1 file changed

Lines changed: 42 additions & 30 deletions

File tree

api/08-How-To/Panels.md

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ In Phoenix Code, Panels are of two types :- `Plugin Panel` and `Bottom Panel`.
99
![Plugin Panel Example](./images/plugin-panel-example.png)
1010

1111

12-
**Bottom Panel** appears on the bottom of the screen. For Example :- *Problems* feature uses the `Bottom Panel`.
12+
**Bottom Panel** appears on the bottom of the screen as a tab. Multiple bottom panels share a tabbed interface where each panel gets its own tab with an icon and title. For Example :- *Git*, *Terminal*, *Problems* panel and many more use the `Bottom Panel`.
1313

1414
![Bottom Panel Example](./images/bottom-panel-example.png)
1515

@@ -150,7 +150,7 @@ You can control the visibility and state of your plugin panel:
150150
## Creating a Bottom Panel
151151

152152
Bottom panels are created similarly to plugin panels but use different methods:
153-
> For `Bottom Panels` creating a toolbar icon is not required.
153+
> For `Bottom Panels` creating a toolbar icon is not required. Each bottom panel appears as a tab in the shared tab bar.
154154

155155
1. **Import required modules**
156156
```jsx
@@ -160,11 +160,21 @@ Bottom panels are created similarly to plugin panels but use different methods:
160160
2. **Create the bottom panel**
161161
```jsx
162162
const bottomPanel = WorkspaceManager.createBottomPanel(
163-
"myextension.panel",
164-
$panel,
165-
200,
163+
"myextension.panel", // Unique ID using package-style naming
164+
$panel, // jQuery object for panel content
165+
undefined, // minSize (deprecated, pass undefined)
166+
"My Panel", // Title shown on the tab
167+
{
168+
iconSvg: "path/to/icon.svg" // SVG icon for the tab
169+
}
166170
);
167171
```
172+
173+
- **`title`**: The text shown on the panel's tab. If not provided, Phoenix Code uses the text from a `.toolbar .title` element inside your panel, or derives it from the panel ID.
174+
- **`iconSvg`**: Path to an SVG file used as the tab icon. The icon automatically adapts to light and dark themes. If not provided, a default icon is used.
175+
176+
> The `minSize` parameter (third argument) is deprecated and no longer used. Pass `undefined` for this parameter.
177+
168178
> For a detailed description, refer to [this link](https://docs.phcode.dev/api/API-Reference/view/WorkspaceManager#createBottomPanel).
169179
170180
Full Code Example for Bottom Panel:
@@ -189,11 +199,13 @@ Full Code Example for Bottom Panel:
189199
.attr("id", "my-extension-panel")
190200
.html("<h3>My Bottom Panel</h3><p>Hello from the panel!</p>");
191201
192-
// Create the plugin panel
202+
// Create the bottom panel
193203
bottomPanel = WorkspaceManager.createBottomPanel(
194204
"myextension.panel",
195205
$panel,
196-
200,
206+
undefined,
207+
"My Panel",
208+
{ iconSvg: "styles/images/panel-icon-default.svg" }
197209
);
198210
bottomPanel.show();
199211
}
@@ -246,33 +258,33 @@ Bottom panels support similar state management to plugin panels:
246258
}
247259
```
248260
261+
4. **Update Tab Title**
262+
```jsx
263+
bottomPanel.setTitle("New Title");
264+
```
265+
266+
5. **Handle Close Confirmation**
267+
268+
If your panel has unsaved state or running processes, you can register a handler that runs before the panel closes. Return `false` to prevent closing.
269+
```jsx
270+
bottomPanel.registerOnCloseRequestedHandler(async function () {
271+
if (hasUnsavedChanges) {
272+
const confirmed = await showConfirmDialog("Discard changes?");
273+
return confirmed; // true to close, false to cancel
274+
}
275+
return true;
276+
});
277+
```
278+
279+
To programmatically close a panel while respecting its close handler, use `requestClose()`:
280+
```jsx
281+
const wasClosed = await bottomPanel.requestClose();
282+
```
283+
249284
## Best Practices
250285
251286
1. Always use unique, package-style IDs (e.g., "yourextension.panel-name") to avoid conflicts with other extensions.
252287
253288
2. Save panel state (e.g., visibility, size) in preferences if needed, to restore state when the extension is reloaded.
254289
255-
Example CSS for Bottom Panel:
256-
257-
```css
258-
.bottom-panel {
259-
background-color: #f8f9fa;
260-
border-top: 1px solid #ddd;
261-
}
262-
263-
.bottom-panel .toolbar {
264-
padding: 4px 8px;
265-
display: flex;
266-
justify-content: space-between;
267-
align-items: center;
268-
background-color: #e9ecef;
269-
border-bottom: 1px solid #ddd;
270-
}
271-
272-
.bottom-panel .panel-content {
273-
padding: 8px;
274-
overflow-y: auto;
275-
}
276-
```
277-
278290
> For more information about the WorkSpace Manager API, refer to the [Phoenix Code API documentation](https://docs.phcode.dev/api/API-Reference/view/WorkspaceManager).

0 commit comments

Comments
 (0)