diff --git a/src-web/components/HeaderSize.tsx b/src-web/components/HeaderSize.tsx index 07f41996..a5071df1 100644 --- a/src-web/components/HeaderSize.tsx +++ b/src-web/components/HeaderSize.tsx @@ -1,27 +1,31 @@ import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow'; import classNames from 'classnames'; import type { HTMLAttributes, ReactNode } from 'react'; -import { useIsFullscreen } from '../hooks/useIsFullscreen'; -import { useOsInfo } from '../hooks/useOsInfo'; +import React from 'react'; import { useSettings } from '../hooks/useSettings'; +import { useStoplightsVisible } from '../hooks/useStoplightsVisible'; +import { WINDOW_CONTROLS_WIDTH, WindowControls } from './WindowControls'; interface HeaderSizeProps extends HTMLAttributes { children?: ReactNode; size: 'md' | 'lg'; - ignoreStoplights?: boolean; + ignoreControlsSpacing?: boolean; + onlyXWindowControl?: boolean; } +export const HEADER_SIZE_MD = '27px'; +export const HEADER_SIZE_LG = '38px'; + export function HeaderSize({ className, style, size, - ignoreStoplights, - ...props + ignoreControlsSpacing, + onlyXWindowControl, + children, }: HeaderSizeProps) { const settings = useSettings(); - const platform = useOsInfo(); - const fullscreen = useIsFullscreen(); - const stoplightsVisible = platform?.osType === 'macos' && !fullscreen && !ignoreStoplights; + const stoplightsVisible = useStoplightsVisible(); return (
{/* NOTE: This needs display:grid or else the element shrinks (even though scrollable) */} -
+
+ {children} +
+
); } diff --git a/src-web/components/RecentRequestsDropdown.tsx b/src-web/components/RecentRequestsDropdown.tsx index 7b421bcc..8cbd9ae5 100644 --- a/src-web/components/RecentRequestsDropdown.tsx +++ b/src-web/components/RecentRequestsDropdown.tsx @@ -86,8 +86,7 @@ export function RecentRequestsDropdown({ className }: Pick diff --git a/src-web/components/Settings/Settings.tsx b/src-web/components/Settings/Settings.tsx index 8c20d1a8..7ae66668 100644 --- a/src-web/components/Settings/Settings.tsx +++ b/src-web/components/Settings/Settings.tsx @@ -7,11 +7,14 @@ import { capitalize } from '../../lib/capitalize'; import { HStack } from '../core/Stacks'; import { TabContent, Tabs } from '../core/Tabs/Tabs'; import { HeaderSize } from '../HeaderSize'; -import { WindowControls } from '../WindowControls'; import { SettingsAppearance } from './SettingsAppearance'; import { SettingsGeneral } from './SettingsGeneral'; import { SettingsPlugins } from './SettingsPlugins'; +interface Props { + hide?: () => void; +} + enum Tab { General = 'general', Appearance = 'appearance', @@ -20,33 +23,45 @@ enum Tab { const tabs = [Tab.General, Tab.Appearance, Tab.Plugins]; -export default function Settings() { +export default function Settings({ hide }: Props) { const osInfo = useOsInfo(); const [tab, setTab] = useState(Tab.General); // Close settings window on escape // TODO: Could this be put in a better place? Eg. in Rust key listener when creating the window - useKeyPressEvent('Escape', () => getCurrentWebviewWindow().close()); + useKeyPressEvent('Escape', async () => { + if (hide != null) { + // It's being shown in a dialog, so close the dialog + hide(); + } else { + // It's being shown in a window, so close the window + await getCurrentWebviewWindow().close(); + } + }); return (
- - + ) : ( + -
- Settings -
- -
-
+ +
+ Settings +
+
+ + )} (false); - const osInfo = useOsInfo(); - const shouldShow = osInfo?.osType === 'linux' || osInfo?.osType === 'windows'; - if (!shouldShow) { + const stoplightsVisible = useStoplightsVisible(); + if (stoplightsVisible) { return null; } return ( - + {!onlyX && ( <>