Basic Linux/Windows integrated titlebar

This commit is contained in:
Gregory Schier
2024-01-13 23:40:32 -08:00
parent 3086d815c1
commit 3a4a76c58d
11 changed files with 133 additions and 60 deletions

View File

@@ -178,7 +178,7 @@ function HeaderSize({ className, ...props }: HeaderSizeProps) {
className={classNames(
className,
'h-md pt-[1px] flex items-center w-full pr-3 border-b',
platform?.osType === 'Darwin' && 'pl-20',
platform?.osType === 'Darwin' ? 'pl-20' : 'pl-1'
)}
{...props}
/>

View File

@@ -7,12 +7,16 @@ import { RecentRequestsDropdown } from './RecentRequestsDropdown';
import { SettingsDropdown } from './SettingsDropdown';
import { SidebarActions } from './SidebarActions';
import { WorkspaceActionsDropdown } from './WorkspaceActionsDropdown';
import { useOsInfo } from '../hooks/useOsInfo';
import { Button } from './core/Button';
import { appWindow } from '@tauri-apps/api/window';
interface Props {
className?: string;
}
export const WorkspaceHeader = memo(function WorkspaceHeader({ className }: Props) {
const osInfo = useOsInfo();
return (
<HStack
space={2}
@@ -34,6 +38,19 @@ export const WorkspaceHeader = memo(function WorkspaceHeader({ className }: Prop
<div className="flex-1 flex justify-end -mr-2 pointer-events-none">
<SettingsDropdown />
</div>
{osInfo?.osType !== 'Darwin' && (
<HStack className="ml-3" space={1} alignItems="center">
<Button size="sm" onClick={() => appWindow.minimize()}>
-
</Button>
<Button size="sm" onClick={() => appWindow.toggleMaximize()}>
o
</Button>
<Button size="sm" onClick={() => appWindow.close()}>
x
</Button>
</HStack>
)}
</HStack>
);
});

View File

@@ -1,8 +1,8 @@
import type { OsType } from '@tauri-apps/api/os';
import { useEffect, useRef } from 'react';
import { capitalize } from '../lib/capitalize';
import { debounce } from '../lib/debounce';
import { useOsInfo } from './useOsInfo';
import type {OsType} from '@tauri-apps/api/os';
import {useEffect, useRef} from 'react';
import {capitalize} from '../lib/capitalize';
import {debounce} from '../lib/debounce';
import {useOsInfo} from './useOsInfo';
export type HotkeyAction =
| 'request.send'
@@ -87,6 +87,8 @@ export function useAnyHotkey(
currentKeys.current.add(normalizeKey(e.key, os));
console.log("HOTKEY", e.key);
for (const [hkAction, hkKeys] of Object.entries(hotkeys) as [HotkeyAction, string[]][]) {
for (const hkKey of hkKeys) {
const keys = hkKey.split('+');

View File

@@ -6,7 +6,11 @@
html,
body,
#root {
@apply w-full h-full overflow-hidden bg-gray-50 text-gray-900;
@apply w-full h-full;
}
#root {
@apply bg-gray-50 text-gray-900 overflow-hidden rounded-lg;
}
/* Setup default transitions for elements */