From 35e25842befdea1ebd1de232530f02c127a0a19e Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Sat, 1 Apr 2023 20:58:53 -0700 Subject: [PATCH] Refactor sidebar display --- src-web/components/App.tsx | 3 +- src-web/components/ResponsePane.tsx | 4 +-- src-web/components/SidebarActions.tsx | 8 ++--- src-web/components/Workspace.tsx | 34 +++++++++++++--------- src-web/hooks/useIntrospectGraphQL.ts | 7 +++-- src-web/hooks/useSidebarDisplay.ts | 42 --------------------------- src-web/hooks/useSidebarHidden.ts | 20 +++++++++++++ src-web/hooks/useSidebarWidth.ts | 10 +++++++ src-web/hooks/useTauriListeners.ts | 8 ++--- 9 files changed, 67 insertions(+), 69 deletions(-) delete mode 100644 src-web/hooks/useSidebarDisplay.ts create mode 100644 src-web/hooks/useSidebarHidden.ts create mode 100644 src-web/hooks/useSidebarWidth.ts diff --git a/src-web/components/App.tsx b/src-web/components/App.tsx index c6ce8d2f..b7acdb52 100644 --- a/src-web/components/App.tsx +++ b/src-web/components/App.tsx @@ -1,5 +1,6 @@ import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { persistQueryClient } from '@tanstack/react-query-persist-client'; import { MotionConfig } from 'framer-motion'; import { Suspense } from 'react'; @@ -45,7 +46,7 @@ export function App() { - {/**/} + diff --git a/src-web/components/ResponsePane.tsx b/src-web/components/ResponsePane.tsx index e23f1914..0f83db69 100644 --- a/src-web/components/ResponsePane.tsx +++ b/src-web/components/ResponsePane.tsx @@ -78,7 +78,7 @@ export const ResponsePane = memo(function ResponsePane({ style, className }: Pro label: viewMode === 'pretty' ? 'View Raw' : 'View Prettified', onSelect: toggleViewMode, }, - { type: 'separator' }, + { type: 'separator', label: 'Actions' }, { label: 'Clear Response', onSelect: deleteResponse.mutate, @@ -90,7 +90,7 @@ export const ResponsePane = memo(function ResponsePane({ style, className }: Pro hidden: responses.length <= 1, disabled: responses.length === 0, }, - { type: 'separator' }, + { type: 'separator', label: 'History' }, ...responses.slice(0, 10).map((r) => ({ label: r.status + ' - ' + r.elapsed + ' ms', leftSlot: activeResponse?.id === r.id ? : <>, diff --git a/src-web/components/SidebarActions.tsx b/src-web/components/SidebarActions.tsx index 9fcb399b..7b8df0d7 100644 --- a/src-web/components/SidebarActions.tsx +++ b/src-web/components/SidebarActions.tsx @@ -1,10 +1,10 @@ import { memo, useCallback } from 'react'; import { useCreateRequest } from '../hooks/useCreateRequest'; -import { useSidebarDisplay } from '../hooks/useSidebarDisplay'; +import { useSidebarHidden } from '../hooks/useSidebarHidden'; import { IconButton } from './core/IconButton'; export const SidebarActions = memo(function SidebarDisplayToggle() { - const sidebarDisplay = useSidebarDisplay(); + const { hidden, toggle } = useSidebarHidden(); const createRequest = useCreateRequest({ navigateAfter: true }); const handleCreateRequest = useCallback(() => { createRequest.mutate({ name: 'New Request' }); @@ -13,11 +13,11 @@ export const SidebarActions = memo(function SidebarDisplayToggle() { return ( <>