diff --git a/apps/yaak-client/components/Workspace.tsx b/apps/yaak-client/components/Workspace.tsx index 29e9af6e..1012aaca 100644 --- a/apps/yaak-client/components/Workspace.tsx +++ b/apps/yaak-client/components/Workspace.tsx @@ -3,8 +3,7 @@ import { settingsAtom, workspacesAtom } from '@yaakapp-internal/models'; import classNames from 'classnames'; import { useAtomValue } from 'jotai'; import * as m from 'motion/react-m'; -import type { CSSProperties } from 'react'; -import { useCallback, useMemo, useRef, useState } from 'react'; +import { useMemo } from 'react'; import { useEnsureActiveCookieJar, useSubscribeActiveCookieJarId, @@ -40,19 +39,16 @@ import { HStack } from './core/Stacks'; import { ErrorBoundary } from './ErrorBoundary'; import { FolderLayout } from './FolderLayout'; import { GrpcConnectionLayout } from './GrpcConnectionLayout'; -import { HeaderSize } from '@yaakapp-internal/ui'; +import { HeaderSize, SidebarLayout } from '@yaakapp-internal/ui'; import { HttpRequestLayout } from './HttpRequestLayout'; import { Overlay } from './Overlay'; -import { ResizeHandle, type ResizeHandleEvent } from '@yaakapp-internal/ui'; import Sidebar from './Sidebar'; import { SidebarActions } from './SidebarActions'; import { WebsocketRequestLayout } from './WebsocketRequestLayout'; import { WorkspaceHeader } from './WorkspaceHeader'; -const side = { gridArea: 'side' }; const head = { gridArea: 'head' }; const body = { gridArea: 'body' }; -const drag = { gridArea: 'drag' }; export function Workspace() { // First, subscribe to some things applicable to workspaces @@ -66,50 +62,6 @@ export function Workspace() { const [floatingSidebarHidden, setFloatingSidebarHidden] = useFloatingSidebarHidden(); const activeEnvironment = useAtomValue(activeEnvironmentAtom); const floating = useShouldFloatSidebar(); - const [isResizing, setIsResizing] = useState(false); - const startWidth = useRef(null); - - const handleResizeMove = useCallback( - async ({ x, xStart }: ResizeHandleEvent) => { - if (width == null || startWidth.current == null) return; - - const newWidth = startWidth.current + (x - xStart); - if (newWidth < 50) { - if (!sidebarHidden) await setSidebarHidden(true); - resetWidth(); - } else { - if (sidebarHidden) await setSidebarHidden(false); - setWidth(newWidth); - } - }, - [width, sidebarHidden, setSidebarHidden, resetWidth, setWidth], - ); - - const handleResizeStart = useCallback(() => { - startWidth.current = width ?? null; - setIsResizing(true); - }, [width]); - - const handleResizeEnd = useCallback(() => { - setIsResizing(false); - startWidth.current = null; - }, []); - - const sideWidth = sidebarHidden ? 0 : width; - const styles = useMemo( - () => ({ - gridTemplate: floating - ? ` - ' ${head.gridArea}' auto - ' ${body.gridArea}' minmax(0,1fr) - / 1fr` - : ` - ' ${head.gridArea} ${head.gridArea} ${head.gridArea}' auto - ' ${side.gridArea} ${drag.gridArea} ${body.gridArea}' minmax(0,1fr) - / ${sideWidth}px 0 1fr`, - }), - [sideWidth, floating], - ); const environmentBgStyle = useMemo(() => { if (activeEnvironment?.color == null) return undefined; @@ -122,86 +74,87 @@ export function Workspace() { return null; } - return ( -
- {floating ? ( - setFloatingSidebarHidden(true)} - zIndex={20} - > - - - - - - - - - - ) : ( - <> -
- - - -
- - - )} - -
-
-
-
- - - - +
+
+
+
+ + + ); + + const workspaceBody = ( + + + + ); + + const sidebarContent = ( +
+ +
); + + return ( +
+ {header} + {floating ? ( + <> + setFloatingSidebarHidden(true)} + zIndex={20} + > + + + + + + + + + + {workspaceBody} + + ) : ( + + )} +
+ ); } function WorkspaceBody() { diff --git a/apps/yaak-proxy/components/ExchangesTable.tsx b/apps/yaak-proxy/components/ExchangesTable.tsx index 1a49c26c..d24b3a83 100644 --- a/apps/yaak-proxy/components/ExchangesTable.tsx +++ b/apps/yaak-proxy/components/ExchangesTable.tsx @@ -13,15 +13,16 @@ import classNames from 'classnames'; interface Props { exchanges: HttpExchange[]; style?: React.CSSProperties; + className?: string; } -export function ExchangesTable({ exchanges, style }: Props) { +export function ExchangesTable({ exchanges, style, className }: Props) { if (exchanges.length === 0) { return

No traffic yet

; } return ( - +
Method diff --git a/apps/yaak-proxy/components/ProxyLayout.tsx b/apps/yaak-proxy/components/ProxyLayout.tsx index 60225c71..ac0612a1 100644 --- a/apps/yaak-proxy/components/ProxyLayout.tsx +++ b/apps/yaak-proxy/components/ProxyLayout.tsx @@ -1,6 +1,7 @@ -import { HeaderSize, SplitLayout } from '@yaakapp-internal/ui'; +import { HeaderSize, SidebarLayout } from '@yaakapp-internal/ui'; import classNames from 'classnames'; import { useAtomValue } from 'jotai'; +import { useLocalStorage } from 'react-use'; import { useRpcQueryWithEvent } from '../hooks/useRpcQueryWithEvent'; import { getOsType } from '../lib/tauri'; import { ActionIconButton } from './ActionIconButton'; @@ -10,6 +11,7 @@ import { filteredExchangesAtom, Sidebar } from './Sidebar'; export function ProxyLayout() { const os = getOsType(); const exchanges = useAtomValue(filteredExchangesAtom); + const [sidebarWidth, setSidebarWidth] = useLocalStorage('sidebar_width', 250); const { data: proxyState } = useRpcQueryWithEvent('get_proxy_state', {}, 'proxy_state_changed'); const isRunning = proxyState?.state === 'running'; @@ -56,13 +58,13 @@ export function ProxyLayout() { - } - secondSlot={({ style }) => } - /> + } + > + + ); } diff --git a/apps/yaak-proxy/components/Sidebar.tsx b/apps/yaak-proxy/components/Sidebar.tsx index 22131b06..73203536 100644 --- a/apps/yaak-proxy/components/Sidebar.tsx +++ b/apps/yaak-proxy/components/Sidebar.tsx @@ -190,17 +190,14 @@ function ItemInner({ item }: { item: SidebarItem }) { ); } -export function Sidebar({ style }: { style?: React.CSSProperties }) { +export function Sidebar() { const tree = useAtomValue(sidebarTreeAtom); const treeId = SIDEBAR_TREE_ID; const getItemKey = useCallback((item: SidebarItem) => item.id, []); return ( -