|
1 | | -import { useEffect, useRef, useState } from 'react'; |
| 1 | +import { useEffect, useMemo, useRef, useState } from 'react'; |
2 | 2 | import type { LaunchTarget } from '../../Launcher'; |
3 | 3 | import type { PanelType, UserWorkspacePreset, WorkspaceName } from '../../core/types'; |
4 | 4 | import { GitMenu, type GitNotice } from './GitMenu'; |
| 5 | +import { getAppWindow, IS_MAC } from './platform'; |
5 | 6 | import { ProjectMenu } from './ProjectMenu'; |
| 7 | +import { WindowControls } from './WindowControls'; |
6 | 8 | import { WorkspaceMenu } from './WorkspaceMenu'; |
7 | 9 | import type { ProjectStatusResult, TauriInvoke } from './types'; |
8 | 10 |
|
@@ -46,6 +48,11 @@ export function TopBar({ |
46 | 48 | const [openMenu, setOpenMenu] = useState<OpenMenu>(null); |
47 | 49 | const [gitNotice, setGitNotice] = useState<GitNotice | null>(null); |
48 | 50 | const headerRef = useRef<HTMLElement>(null); |
| 51 | + /* Present only inside the Tauri desktop shell. On macOS the native traffic |
| 52 | + lights handle min/max/close, so we draw our own controls only off-mac and |
| 53 | + instead inset the left edge to clear the overlaid traffic lights. */ |
| 54 | + const appWindow = useMemo(() => getAppWindow(), []); |
| 55 | + const macInset = appWindow !== null && IS_MAC; |
49 | 56 | const [status, setStatus] = useState<ProjectStatusResult>({ |
50 | 57 | path: '', |
51 | 58 | name: 'polypore', |
@@ -114,7 +121,11 @@ export function TopBar({ |
114 | 121 | }, [openMenu]); |
115 | 122 |
|
116 | 123 | return ( |
117 | | - <header className="topbar" ref={headerRef}> |
| 124 | + <header |
| 125 | + className={`topbar${macInset ? ' topbar--mac' : ''}`} |
| 126 | + ref={headerRef} |
| 127 | + data-tauri-drag-region |
| 128 | + > |
118 | 129 | <ProjectMenu |
119 | 130 | status={status} |
120 | 131 | onStatusChange={setStatus} |
@@ -151,7 +162,7 @@ export function TopBar({ |
151 | 162 | render elsewhere when they're real. */} |
152 | 163 | <button className="segment settings-button" title="settings" aria-label="settings" onClick={onOpenSettings}>settings</button> |
153 | 164 | <button className="segment help-button" title="help" aria-label="help" onClick={onOpenHelp}>help</button> |
154 | | - <div className="segment segment--brand">polypore v{__APP_VERSION__}</div> |
| 165 | + {appWindow && !IS_MAC && <WindowControls appWindow={appWindow} />} |
155 | 166 | {gitNotice && ( |
156 | 167 | <div |
157 | 168 | className={`git-toast git-toast--${gitNotice.tone}`} |
|
0 commit comments