@peers-app/peers-ui 0.19.10 → 0.19.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/dist/components/group-switcher.js +3 -4
- package/dist/components/voice-playback.d.ts +15 -0
- package/dist/components/voice-playback.js +86 -0
- package/dist/components/voice-subscribe-events.d.ts +0 -4
- package/dist/index.d.ts +10 -2
- package/dist/index.js +23 -2
- package/dist/operator-console/operator-console-state.d.ts +49 -0
- package/dist/operator-console/operator-console-state.js +97 -0
- package/dist/operator-console/operator-console.d.ts +32 -0
- package/dist/operator-console/operator-console.js +88 -0
- package/dist/root-layout/global-overlays.d.ts +37 -0
- package/dist/root-layout/global-overlays.js +37 -0
- package/dist/root-layout/layout-picker.d.ts +9 -0
- package/dist/root-layout/layout-picker.js +22 -0
- package/dist/root-layout/layouts/full-screen-layout.d.ts +12 -0
- package/dist/root-layout/layouts/full-screen-layout.js +60 -0
- package/dist/root-layout/layouts/tabs-with-console-layout.d.ts +20 -0
- package/dist/root-layout/layouts/tabs-with-console-layout.js +158 -0
- package/dist/root-layout/root-layout-host.d.ts +19 -0
- package/dist/root-layout/root-layout-host.js +88 -0
- package/dist/root-layout/root-layout-registry.d.ts +15 -0
- package/dist/root-layout/root-layout-registry.js +50 -0
- package/dist/root-layout/root-layout-state.d.ts +23 -0
- package/dist/root-layout/root-layout-state.js +54 -0
- package/dist/root-layout/root-layout.d.ts +30 -0
- package/dist/root-layout/root-layout.js +12 -0
- package/dist/screens/network-viewer/connection-troubleshooter.js +7 -11
- package/dist/screens/settings/settings-page.js +2 -1
- package/dist/screens/setup-user.js +2 -7
- package/dist/tabs-layout/tabs-layout.d.ts +48 -4
- package/dist/tabs-layout/tabs-layout.js +27 -53
- package/dist/tabs-layout/tabs-state.d.ts +10 -0
- package/dist/tabs-layout/tabs-state.js +33 -1
- package/package.json +3 -3
- package/src/components/group-switcher.tsx +5 -7
- package/src/components/voice-playback.tsx +97 -0
- package/src/components/voice-subscribe-events.ts +0 -4
- package/src/index.tsx +24 -2
- package/src/operator-console/operator-console-state.ts +119 -0
- package/src/operator-console/operator-console.tsx +233 -0
- package/src/root-layout/global-overlays.ts +50 -0
- package/src/root-layout/layout-picker.tsx +47 -0
- package/src/root-layout/layouts/full-screen-layout.tsx +144 -0
- package/src/root-layout/layouts/tabs-with-console-layout.tsx +260 -0
- package/src/root-layout/root-layout-host.tsx +113 -0
- package/src/root-layout/root-layout-registry.ts +51 -0
- package/src/root-layout/root-layout-state.ts +55 -0
- package/src/root-layout/root-layout.ts +32 -0
- package/src/screens/network-viewer/connection-troubleshooter.tsx +10 -14
- package/src/screens/settings/settings-page.tsx +7 -1
- package/src/screens/setup-user.tsx +2 -9
- package/src/tabs-layout/tabs-layout.tsx +28 -74
- package/src/tabs-layout/tabs-state.ts +31 -0
- package/dist/components/chat-overlay.d.ts +0 -14
- package/dist/components/chat-overlay.js +0 -477
- package/src/components/chat-overlay.tsx +0 -854
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operator Console — presentational panel
|
|
3
|
+
*
|
|
4
|
+
* The console's visual chrome only: a header toolbar (dock buttons, maximize/restore,
|
|
5
|
+
* collapse) plus the body region. It fills its container (`height/width: 100%`) and has
|
|
6
|
+
* no positioning of its own — the host layout (e.g. the `tabs-with-console` root layout)
|
|
7
|
+
* owns the split sizing, the resize handle, the collapsed edge strip, and where the panel
|
|
8
|
+
* is placed. Command input, output blocks, and the engine arrive later.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type React from "react";
|
|
12
|
+
import { useObservable } from "../hooks";
|
|
13
|
+
import { colorMode } from "../screens/settings/color-mode-dropdown";
|
|
14
|
+
import {
|
|
15
|
+
type ConsoleDock,
|
|
16
|
+
operatorConsolePanel,
|
|
17
|
+
setConsoleDock,
|
|
18
|
+
setConsoleMaximized,
|
|
19
|
+
toggleConsole,
|
|
20
|
+
} from "./operator-console-state";
|
|
21
|
+
|
|
22
|
+
/** Resolved color palette for the console chrome. */
|
|
23
|
+
export interface ConsoleTheme {
|
|
24
|
+
bg: string;
|
|
25
|
+
headerBg: string;
|
|
26
|
+
border: string;
|
|
27
|
+
text: string;
|
|
28
|
+
muted: string;
|
|
29
|
+
hover: string;
|
|
30
|
+
accent: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the console color palette for the active color mode. Shared by the panel and by
|
|
35
|
+
* the host layout (so its collapsed strip and resize divider match the panel chrome).
|
|
36
|
+
*/
|
|
37
|
+
export function getConsoleTheme(isDark: boolean): ConsoleTheme {
|
|
38
|
+
return {
|
|
39
|
+
bg: isDark ? "#1e1e1e" : "#ffffff",
|
|
40
|
+
headerBg: isDark ? "#252526" : "#f3f3f3",
|
|
41
|
+
border: isDark ? "#3c3c3c" : "#dee2e6",
|
|
42
|
+
text: isDark ? "#cccccc" : "#1e1e1e",
|
|
43
|
+
muted: isDark ? "#8c8c8c" : "#6c757d",
|
|
44
|
+
hover: isDark ? "#2a2d2e" : "#e8e8e8",
|
|
45
|
+
accent: "#0d6efd",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The Operator Console panel chrome. Renders as an in-flow flex column that fills its
|
|
51
|
+
* container; the parent layout decides the panel's size and placement. Reads dock and
|
|
52
|
+
* maximized state from `operatorConsolePanel` to drive the header toolbar.
|
|
53
|
+
*/
|
|
54
|
+
export const OperatorConsolePanel: React.FC = () => {
|
|
55
|
+
const [state] = useObservable(operatorConsolePanel);
|
|
56
|
+
const [mode] = useObservable(colorMode);
|
|
57
|
+
|
|
58
|
+
const { dock, maximized } = state;
|
|
59
|
+
const theme = getConsoleTheme(mode === "dark");
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div
|
|
63
|
+
style={{
|
|
64
|
+
width: "100%",
|
|
65
|
+
height: "100%",
|
|
66
|
+
backgroundColor: theme.bg,
|
|
67
|
+
color: theme.text,
|
|
68
|
+
display: "flex",
|
|
69
|
+
flexDirection: "column",
|
|
70
|
+
overflow: "hidden",
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
{/* Header toolbar */}
|
|
74
|
+
<div
|
|
75
|
+
style={{
|
|
76
|
+
display: "flex",
|
|
77
|
+
alignItems: "center",
|
|
78
|
+
justifyContent: "space-between",
|
|
79
|
+
height: "34px",
|
|
80
|
+
flex: "0 0 auto",
|
|
81
|
+
padding: "0 8px",
|
|
82
|
+
backgroundColor: theme.headerBg,
|
|
83
|
+
borderBottom: `1px solid ${theme.border}`,
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
<div style={{ display: "flex", alignItems: "center", gap: "6px", fontSize: "12px" }}>
|
|
87
|
+
<i className="bi-terminal" />
|
|
88
|
+
<span style={{ fontWeight: 500 }}>Console</span>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<div style={{ display: "flex", alignItems: "center", gap: "2px" }}>
|
|
92
|
+
<DockButton
|
|
93
|
+
dock="left"
|
|
94
|
+
active={dock === "left"}
|
|
95
|
+
disabled={maximized}
|
|
96
|
+
theme={theme}
|
|
97
|
+
icon="bi-arrow-bar-left"
|
|
98
|
+
label="Dock left"
|
|
99
|
+
/>
|
|
100
|
+
<DockButton
|
|
101
|
+
dock="bottom"
|
|
102
|
+
active={dock === "bottom"}
|
|
103
|
+
disabled={maximized}
|
|
104
|
+
theme={theme}
|
|
105
|
+
icon="bi-arrow-bar-down"
|
|
106
|
+
label="Dock bottom"
|
|
107
|
+
/>
|
|
108
|
+
<DockButton
|
|
109
|
+
dock="right"
|
|
110
|
+
active={dock === "right"}
|
|
111
|
+
disabled={maximized}
|
|
112
|
+
theme={theme}
|
|
113
|
+
icon="bi-arrow-bar-right"
|
|
114
|
+
label="Dock right"
|
|
115
|
+
/>
|
|
116
|
+
|
|
117
|
+
<span
|
|
118
|
+
style={{ width: "1px", height: "18px", backgroundColor: theme.border, margin: "0 4px" }}
|
|
119
|
+
/>
|
|
120
|
+
|
|
121
|
+
<ToolbarButton
|
|
122
|
+
theme={theme}
|
|
123
|
+
icon={maximized ? "bi-fullscreen-exit" : "bi-arrows-fullscreen"}
|
|
124
|
+
label={maximized ? "Restore" : "Maximize"}
|
|
125
|
+
onClick={() => setConsoleMaximized(!maximized)}
|
|
126
|
+
/>
|
|
127
|
+
<ToolbarButton
|
|
128
|
+
theme={theme}
|
|
129
|
+
icon="bi-chevron-down"
|
|
130
|
+
label="Collapse (Ctrl+`)"
|
|
131
|
+
onClick={toggleConsole}
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
{/* Body placeholder (content arrives in a later step) */}
|
|
137
|
+
<div
|
|
138
|
+
style={{
|
|
139
|
+
flex: "1 1 auto",
|
|
140
|
+
overflow: "auto",
|
|
141
|
+
display: "flex",
|
|
142
|
+
alignItems: "center",
|
|
143
|
+
justifyContent: "center",
|
|
144
|
+
color: theme.muted,
|
|
145
|
+
fontSize: "13px",
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
<div style={{ textAlign: "center" }}>
|
|
149
|
+
<i
|
|
150
|
+
className="bi-terminal"
|
|
151
|
+
style={{ fontSize: "24px", display: "block", marginBottom: "6px" }}
|
|
152
|
+
/>
|
|
153
|
+
Operator Console
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
interface ButtonTheme {
|
|
161
|
+
text: string;
|
|
162
|
+
muted: string;
|
|
163
|
+
hover: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
interface ToolbarButtonProps {
|
|
167
|
+
theme: ButtonTheme;
|
|
168
|
+
icon: string;
|
|
169
|
+
label: string;
|
|
170
|
+
onClick: () => void;
|
|
171
|
+
active?: boolean;
|
|
172
|
+
disabled?: boolean;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** A small, icon-only button used in the console header toolbar. */
|
|
176
|
+
function ToolbarButton({ theme, icon, label, onClick, active, disabled }: ToolbarButtonProps) {
|
|
177
|
+
return (
|
|
178
|
+
<button
|
|
179
|
+
type="button"
|
|
180
|
+
title={label}
|
|
181
|
+
aria-label={label}
|
|
182
|
+
disabled={disabled}
|
|
183
|
+
onClick={onClick}
|
|
184
|
+
style={{
|
|
185
|
+
display: "flex",
|
|
186
|
+
alignItems: "center",
|
|
187
|
+
justifyContent: "center",
|
|
188
|
+
width: "28px",
|
|
189
|
+
height: "26px",
|
|
190
|
+
border: "none",
|
|
191
|
+
borderRadius: "4px",
|
|
192
|
+
background: active ? theme.hover : "transparent",
|
|
193
|
+
color: active ? theme.text : theme.muted,
|
|
194
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
195
|
+
opacity: disabled ? 0.4 : 1,
|
|
196
|
+
fontSize: "14px",
|
|
197
|
+
}}
|
|
198
|
+
onMouseEnter={(e) => {
|
|
199
|
+
if (!disabled) e.currentTarget.style.backgroundColor = theme.hover;
|
|
200
|
+
}}
|
|
201
|
+
onMouseLeave={(e) => {
|
|
202
|
+
e.currentTarget.style.backgroundColor = active ? theme.hover : "transparent";
|
|
203
|
+
}}
|
|
204
|
+
>
|
|
205
|
+
<i className={icon} />
|
|
206
|
+
</button>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
interface DockButtonProps {
|
|
211
|
+
dock: ConsoleDock;
|
|
212
|
+
active: boolean;
|
|
213
|
+
disabled: boolean;
|
|
214
|
+
theme: ButtonTheme;
|
|
215
|
+
icon: string;
|
|
216
|
+
label: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** Header button that docks the console to a given edge. */
|
|
220
|
+
function DockButton({ dock, active, disabled, theme, icon, label }: DockButtonProps) {
|
|
221
|
+
return (
|
|
222
|
+
<ToolbarButton
|
|
223
|
+
theme={theme}
|
|
224
|
+
icon={icon}
|
|
225
|
+
label={label}
|
|
226
|
+
active={active}
|
|
227
|
+
disabled={disabled}
|
|
228
|
+
onClick={() => setConsoleDock(dock)}
|
|
229
|
+
/>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export default OperatorConsolePanel;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { observable } from "@peers-app/peers-sdk";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A globally-mounted overlay component contributed by a package (or peers-ui itself).
|
|
6
|
+
*
|
|
7
|
+
* Overlays are rendered by {@link RootLayoutHost} above every root layout (alongside the
|
|
8
|
+
* command palette), so they remain visible regardless of which tab/app is active. Each
|
|
9
|
+
* overlay is responsible for deciding its own visibility (e.g. returning `null` when it
|
|
10
|
+
* should be hidden); the registry only controls whether the component is mounted.
|
|
11
|
+
*/
|
|
12
|
+
export interface GlobalOverlay {
|
|
13
|
+
/** Stable id. Re-registering with the same id replaces the prior entry. */
|
|
14
|
+
id: string;
|
|
15
|
+
/** The component rendered by the host. It owns its own visibility and positioning. */
|
|
16
|
+
Component: React.ComponentType;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Reactive registry of global overlays rendered by {@link RootLayoutHost}.
|
|
21
|
+
*
|
|
22
|
+
* This mirrors the command-palette registry pattern: a package's UI bundle calls
|
|
23
|
+
* {@link registerGlobalOverlay} when it loads, and the host re-renders because this is an
|
|
24
|
+
* observable. Because peers-core (and other packages) externalize `@peers-app/peers-ui`
|
|
25
|
+
* to the shared `window.PeersUI` singleton, they register into this exact instance.
|
|
26
|
+
*/
|
|
27
|
+
export const globalOverlays = observable<GlobalOverlay[]>([]);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Register a global overlay component, replacing any existing overlay with the same id.
|
|
31
|
+
*
|
|
32
|
+
* @param id Stable identifier for the overlay (used for replacement/removal).
|
|
33
|
+
* @param Component The React component to mount globally.
|
|
34
|
+
*/
|
|
35
|
+
export function registerGlobalOverlay(id: string, Component: React.ComponentType): void {
|
|
36
|
+
const next = globalOverlays().filter((o) => o.id !== id);
|
|
37
|
+
next.push({ id, Component });
|
|
38
|
+
globalOverlays(next);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Remove a previously-registered global overlay by id. No-op if the id is not registered.
|
|
43
|
+
*
|
|
44
|
+
* @param id The id passed to {@link registerGlobalOverlay}.
|
|
45
|
+
*/
|
|
46
|
+
export function unregisterGlobalOverlay(id: string): void {
|
|
47
|
+
const current = globalOverlays();
|
|
48
|
+
const next = current.filter((o) => o.id !== id);
|
|
49
|
+
if (next.length !== current.length) globalOverlays(next);
|
|
50
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout picker — Settings entry point for choosing the root layout.
|
|
3
|
+
*
|
|
4
|
+
* Lists every registered {@link RootLayout} and writes the selection to
|
|
5
|
+
* `selectedRootLayoutId` (per-device). `RootLayoutHost` subscribes to that pvar, so the
|
|
6
|
+
* layout swaps live on select. Mirrors the `ColorModeDropdown` pattern.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useObservable } from "../hooks";
|
|
10
|
+
import { getRootLayouts } from "./root-layout-registry";
|
|
11
|
+
import { selectedRootLayoutId, setRootLayout } from "./root-layout-state";
|
|
12
|
+
|
|
13
|
+
/** Dropdown that selects the active root layout. */
|
|
14
|
+
export const LayoutPicker = () => {
|
|
15
|
+
const [selectedId] = useObservable(selectedRootLayoutId);
|
|
16
|
+
const layouts = getRootLayouts();
|
|
17
|
+
const active = layouts.find((layout) => layout.id === selectedId);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div className="dropdown">
|
|
21
|
+
<button
|
|
22
|
+
className="btn btn-secondary dropdown-toggle"
|
|
23
|
+
type="button"
|
|
24
|
+
id="layoutPickerDropdown"
|
|
25
|
+
data-bs-toggle="dropdown"
|
|
26
|
+
aria-expanded="false"
|
|
27
|
+
>
|
|
28
|
+
Layout: {active?.name ?? selectedId}
|
|
29
|
+
</button>
|
|
30
|
+
<ul className="dropdown-menu" aria-labelledby="layoutPickerDropdown">
|
|
31
|
+
{layouts.map((layout) => (
|
|
32
|
+
<li key={layout.id}>
|
|
33
|
+
<button
|
|
34
|
+
type="button"
|
|
35
|
+
className="dropdown-item"
|
|
36
|
+
onClick={() => setRootLayout(layout.id)}
|
|
37
|
+
>
|
|
38
|
+
<i className={`${layout.iconClassName} me-2`} />
|
|
39
|
+
{layout.name} {layout.id === selectedId && "✓"}
|
|
40
|
+
<div className="small text-muted ms-4">{layout.description}</div>
|
|
41
|
+
</button>
|
|
42
|
+
</li>
|
|
43
|
+
))}
|
|
44
|
+
</ul>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Full-screen root layout — one screen at a time, no tab strip.
|
|
3
|
+
*
|
|
4
|
+
* Renders only the active tab's content under a minimal header. All navigation flows
|
|
5
|
+
* through the command palette (Cmd/Ctrl+K), which {@link RootLayoutHost} always mounts,
|
|
6
|
+
* plus a Home button back to the app launcher. While mounted, this layout enables
|
|
7
|
+
* single-tab mode (see `setSingleTabMode`) so opening an app replaces the current screen
|
|
8
|
+
* instead of accumulating tabs. This is non-destructive: any tabs opened under a multi-tab
|
|
9
|
+
* layout are left untouched and reappear if the user switches back.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { type ReactNode, useEffect } from "react";
|
|
13
|
+
import { openCommandPalette } from "../../command-palette/command-palette";
|
|
14
|
+
import { GroupSwitcher } from "../../components/group-switcher";
|
|
15
|
+
import { isDesktop } from "../../globals";
|
|
16
|
+
import { useObservable } from "../../hooks";
|
|
17
|
+
import { colorMode } from "../../screens/settings/color-mode-dropdown";
|
|
18
|
+
import { TabContent, TabErrorBoundary } from "../../tabs-layout/tabs-layout";
|
|
19
|
+
import {
|
|
20
|
+
activeTabId,
|
|
21
|
+
activeTabs,
|
|
22
|
+
launcherApp,
|
|
23
|
+
setSingleTabMode,
|
|
24
|
+
} from "../../tabs-layout/tabs-state";
|
|
25
|
+
|
|
26
|
+
const isMac =
|
|
27
|
+
typeof navigator !== "undefined" ? /Mac|iPod|iPhone|iPad/.test(navigator.userAgent) : false;
|
|
28
|
+
const paletteHint = isMac ? "⌘K" : "Ctrl+K";
|
|
29
|
+
|
|
30
|
+
/** The full-screen layout body: minimal header + the single active screen. */
|
|
31
|
+
export function FullScreenLayout() {
|
|
32
|
+
const [mode] = useObservable(colorMode);
|
|
33
|
+
const [tabs] = useObservable(activeTabs);
|
|
34
|
+
const [activeId] = useObservable(activeTabId);
|
|
35
|
+
useObservable(isDesktop);
|
|
36
|
+
const isMobile = !isDesktop();
|
|
37
|
+
|
|
38
|
+
// Single-tab navigation while this layout is active; restore on unmount/layout swap.
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
setSingleTabMode(true);
|
|
41
|
+
return () => setSingleTabMode(false);
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
const activeTab = tabs.find((t) => t.tabId === activeId) ?? launcherApp;
|
|
45
|
+
const isLauncher = activeTab.packageId === "launcher" || activeTab.tabId === "launcher";
|
|
46
|
+
const isLight = mode === "light";
|
|
47
|
+
|
|
48
|
+
const title = isLauncher ? "Apps" : activeTab.title;
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div
|
|
52
|
+
className="d-flex flex-column"
|
|
53
|
+
style={{ height: "calc(100vh - 25px)", overflow: "hidden" }}
|
|
54
|
+
>
|
|
55
|
+
{/* Minimal header */}
|
|
56
|
+
<div
|
|
57
|
+
className={`border-bottom d-flex align-items-center px-1 ${isLight ? "bg-light" : "bg-dark"}`}
|
|
58
|
+
style={{ height: "36px", borderBottomColor: isLight ? "#dee2e6" : "#495057" }}
|
|
59
|
+
>
|
|
60
|
+
<GroupSwitcher colorMode={mode} isMobile={isMobile} />
|
|
61
|
+
|
|
62
|
+
<HeaderButton
|
|
63
|
+
isLight={isLight}
|
|
64
|
+
active={isLauncher}
|
|
65
|
+
icon="bi-grid-3x3-gap"
|
|
66
|
+
label="Apps"
|
|
67
|
+
onClick={() => activeTabId("launcher")}
|
|
68
|
+
/>
|
|
69
|
+
|
|
70
|
+
{/* Current screen title */}
|
|
71
|
+
<div className="d-flex align-items-center flex-grow-1 overflow-hidden px-2">
|
|
72
|
+
{!isLauncher && activeTab.iconClassName && (
|
|
73
|
+
<i className={`${activeTab.iconClassName} me-2`} />
|
|
74
|
+
)}
|
|
75
|
+
<span className="text-truncate fw-medium" style={{ fontSize: "13px" }}>
|
|
76
|
+
{title}
|
|
77
|
+
</span>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
{/* Command palette (navigation) */}
|
|
81
|
+
<HeaderButton
|
|
82
|
+
isLight={isLight}
|
|
83
|
+
icon="bi-search"
|
|
84
|
+
label={`Search and navigate (${paletteHint})`}
|
|
85
|
+
onClick={openCommandPalette}
|
|
86
|
+
>
|
|
87
|
+
<span className="d-none d-md-inline ms-1" style={{ fontSize: "11px" }}>
|
|
88
|
+
{paletteHint}
|
|
89
|
+
</span>
|
|
90
|
+
</HeaderButton>
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
{/* The single active screen. Key on tabId so each screen mounts fresh (and the error
|
|
94
|
+
boundary resets) when navigating. */}
|
|
95
|
+
<div className="flex-grow-1 overflow-hidden">
|
|
96
|
+
<TabErrorBoundary key={activeTab.tabId} tabTitle={activeTab.title} tabId={activeTab.tabId}>
|
|
97
|
+
<TabContent tab={activeTab} isMobile={isMobile} isActive />
|
|
98
|
+
</TabErrorBoundary>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface HeaderButtonProps {
|
|
105
|
+
isLight: boolean;
|
|
106
|
+
icon: string;
|
|
107
|
+
label: string;
|
|
108
|
+
onClick: () => void;
|
|
109
|
+
active?: boolean;
|
|
110
|
+
children?: ReactNode;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** A small, transparent header button matching the tabs layout's toolbar styling. */
|
|
114
|
+
function HeaderButton({ isLight, icon, label, onClick, active, children }: HeaderButtonProps) {
|
|
115
|
+
const baseColor = active ? (isLight ? "#0d6efd" : "#ffffff") : isLight ? "#6c757d" : "#adb5bd";
|
|
116
|
+
return (
|
|
117
|
+
<button
|
|
118
|
+
type="button"
|
|
119
|
+
className="btn btn-sm d-flex align-items-center"
|
|
120
|
+
onClick={onClick}
|
|
121
|
+
title={label}
|
|
122
|
+
aria-label={label}
|
|
123
|
+
style={{
|
|
124
|
+
padding: "4px 8px",
|
|
125
|
+
fontSize: "12px",
|
|
126
|
+
borderRadius: "6px",
|
|
127
|
+
border: "none",
|
|
128
|
+
background: "transparent",
|
|
129
|
+
color: baseColor,
|
|
130
|
+
}}
|
|
131
|
+
onMouseEnter={(e) => {
|
|
132
|
+
e.currentTarget.style.backgroundColor = isLight ? "#f8f9fa" : "#495057";
|
|
133
|
+
e.currentTarget.style.color = isLight ? "#0d6efd" : "#ffffff";
|
|
134
|
+
}}
|
|
135
|
+
onMouseLeave={(e) => {
|
|
136
|
+
e.currentTarget.style.backgroundColor = "transparent";
|
|
137
|
+
e.currentTarget.style.color = baseColor;
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
<i className={icon} style={{ fontSize: "14px" }} />
|
|
141
|
+
{children}
|
|
142
|
+
</button>
|
|
143
|
+
);
|
|
144
|
+
}
|