From 09c574bf30fce8ce20ff7d1f2d595ba156bdd1e5 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Sat, 25 Mar 2023 11:06:05 -0700 Subject: [PATCH] Better dropdown separator --- src-web/components/ResponsePane.tsx | 4 +- src-web/components/Sidebar.tsx | 28 +++----------- src-web/components/WorkspaceDropdown.tsx | 21 ++++++---- src-web/components/core/Dropdown.tsx | 49 +++++++++++++++--------- src-web/components/core/Separator.tsx | 29 ++++++++------ tailwind.config.cjs | 3 ++ 6 files changed, 73 insertions(+), 61 deletions(-) diff --git a/src-web/components/ResponsePane.tsx b/src-web/components/ResponsePane.tsx index 8716e7e9..b40a7c49 100644 --- a/src-web/components/ResponsePane.tsx +++ b/src-web/components/ResponsePane.tsx @@ -76,7 +76,7 @@ export const ResponsePane = memo(function ResponsePane({ className }: Props) { label: viewMode === 'pretty' ? 'View Raw' : 'View Prettified', onSelect: toggleViewMode, }, - '-----', + { type: 'separator' }, { label: 'Clear Response', onSelect: deleteResponse.mutate, @@ -88,7 +88,7 @@ export const ResponsePane = memo(function ResponsePane({ className }: Props) { hidden: responses.length <= 1, disabled: responses.length === 0, }, - '-----', + { type: 'separator' }, ...responses.slice(0, 10).map((r) => ({ label: r.status + ' - ' + r.elapsed + ' ms', leftSlot: activeResponse?.id === r.id ? : <>, diff --git a/src-web/components/Sidebar.tsx b/src-web/components/Sidebar.tsx index 378b09e8..b048824f 100644 --- a/src-web/components/Sidebar.tsx +++ b/src-web/components/Sidebar.tsx @@ -74,7 +74,6 @@ export const Sidebar = memo(function Sidebar({ className }: Props) { ); const sidebarStyles = useMemo(() => ({ width: width.value }), [width.value]); - const sidebarWidth = width.value - 1; // Minus 1 for the border return (
@@ -89,6 +88,7 @@ export const Sidebar = memo(function Sidebar({ className }: Props) { > - - + + @@ -119,11 +115,9 @@ export const Sidebar = memo(function Sidebar({ className }: Props) { function SidebarItems({ requests, activeRequestId, - sidebarWidth, }: { requests: HttpRequest[]; activeRequestId?: string; - sidebarWidth: number; }) { const [hoveredIndex, setHoveredIndex] = useState(null); const updateRequest = useUpdateAnyRequest(); @@ -178,7 +172,6 @@ function SidebarItems({ requestName={r.name} workspaceId={r.workspaceId} active={r.id === activeRequestId} - sidebarWidth={sidebarWidth} onMove={handleMove} onEnd={handleEnd} /> @@ -194,12 +187,11 @@ type SidebarItemProps = { requestId: string; requestName: string; workspaceId: string; - sidebarWidth: number; active?: boolean; }; const _SidebarItem = forwardRef(function SidebarItem( - { className, requestName, requestId, workspaceId, active, sidebarWidth }: SidebarItemProps, + { className, requestName, requestId, workspaceId, active }: SidebarItemProps, ref: ForwardedRef, ) { const updateRequest = useUpdateRequest(requestId); @@ -215,7 +207,6 @@ const _SidebarItem = forwardRef(function SidebarItem( el?.select(); }, []); - const itemStyles = useMemo(() => ({ width: sidebarWidth }), [sidebarWidth]); const handleKeyDown = useCallback( (e: KeyboardEvent) => { // Hitting enter on active request during keyboard nav will start edit @@ -242,12 +233,8 @@ const _SidebarItem = forwardRef(function SidebarItem( ); return ( -
  • -
    +
  • +