From 4c5087659be46fac666937d5b6f68e84d59f3da5 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Tue, 21 May 2024 17:56:06 -0700 Subject: [PATCH] Theme system refactor (#31) --- package-lock.json | 2 +- package.json | 2 +- src-tauri/tauri.conf.json | 4 +- src-web/components/BinaryFileEditor.tsx | 6 +- src-web/components/CommandPalette.tsx | 6 +- src-web/components/CookieDialog.tsx | 2 +- src-web/components/DropMarker.tsx | 2 +- src-web/components/EmptyStateText.tsx | 4 +- .../components/EnvironmentActionsDropdown.tsx | 4 +- src-web/components/EnvironmentEditDialog.tsx | 8 +- src-web/components/ExportDataDialog.tsx | 4 +- src-web/components/GlobalHooks.tsx | 5 +- src-web/components/GraphQLEditor.tsx | 4 +- src-web/components/GrpcConnectionLayout.tsx | 5 +- .../components/GrpcConnectionMessagesPane.tsx | 40 +- .../components/GrpcConnectionSetupPane.tsx | 13 +- src-web/components/GrpcEditor.tsx | 6 +- src-web/components/GrpcProtoSelection.tsx | 4 +- src-web/components/ImportCurlButton.tsx | 6 +- src-web/components/Overlay.tsx | 4 +- .../components/RecentConnectionsDropdown.tsx | 13 +- src-web/components/RecentRequestsDropdown.tsx | 4 +- .../components/RecentResponsesDropdown.tsx | 23 +- src-web/components/RequestMethodDropdown.tsx | 3 +- src-web/components/RequestPane.tsx | 12 +- src-web/components/ResizeHandle.tsx | 2 +- src-web/components/ResponsePane.tsx | 75 ++-- src-web/components/RouteError.tsx | 2 +- src-web/components/SettingsDialog.tsx | 2 +- src-web/components/Sidebar.tsx | 164 +++++--- src-web/components/UrlBar.tsx | 5 +- src-web/components/Workspace.tsx | 17 +- .../components/WorkspaceActionsDropdown.tsx | 6 +- src-web/components/WorkspaceHeader.tsx | 12 +- src-web/components/core/Banner.tsx | 11 +- src-web/components/core/Button.tsx | 58 ++- src-web/components/core/Checkbox.tsx | 6 +- src-web/components/core/CountBadge.tsx | 2 +- src-web/components/core/Dialog.tsx | 8 +- src-web/components/core/Dropdown.tsx | 34 +- src-web/components/core/DurationTag.tsx | 5 +- src-web/components/core/Editor/Editor.css | 62 +-- src-web/components/core/Editor/Editor.tsx | 16 +- src-web/components/core/Editor/extensions.ts | 19 +- .../core/Editor/twig/placeholder.ts | 6 +- src-web/components/core/FormattedError.tsx | 2 +- src-web/components/core/Heading.tsx | 2 +- src-web/components/core/HotKey.tsx | 2 +- src-web/components/core/HotKeyLabel.tsx | 2 +- src-web/components/core/HotKeyList.tsx | 2 +- src-web/components/core/HttpMethodTag.tsx | 2 +- src-web/components/core/Icon.tsx | 3 +- src-web/components/core/IconButton.tsx | 3 +- src-web/components/core/InlineCode.tsx | 4 +- src-web/components/core/Input.tsx | 10 +- src-web/components/core/JsonAttributeTree.tsx | 22 +- src-web/components/core/KeyValueRow.tsx | 2 +- src-web/components/core/PairEditor.tsx | 2 +- src-web/components/core/Select.tsx | 4 +- src-web/components/core/Separator.tsx | 12 +- src-web/components/core/SizeTag.tsx | 2 +- src-web/components/core/StatusTag.tsx | 13 +- src-web/components/core/Tabs/Tabs.tsx | 4 +- src-web/components/core/Toast.tsx | 21 +- src-web/components/core/WindowDragRegion.tsx | 17 - .../responseViewers/ImageViewer.tsx | 11 +- .../components/responseViewers/TextViewer.tsx | 1 - .../responseViewers/WebPageViewer.tsx | 2 +- src-web/hooks/Confirm.tsx | 4 +- src-web/hooks/Prompt.tsx | 4 +- src-web/hooks/useKeyValue.ts | 7 +- src-web/hooks/useNotificationToast.tsx | 8 +- src-web/hooks/usePinnedGrpcConnection.ts | 19 + src-web/hooks/usePinnedHttpResponse.ts | 29 +- src-web/lib/fallbackRequestName.ts | 7 +- src-web/lib/indent.ts | 6 + src-web/lib/theme/color.ts | 94 +++++ src-web/lib/theme/theme.test.ts | 25 -- src-web/lib/theme/theme.ts | 172 --------- src-web/lib/theme/window.ts | 355 +++++++++++++++--- src-web/main.css | 6 +- tailwind.config.cjs | 69 ++-- 82 files changed, 909 insertions(+), 739 deletions(-) delete mode 100644 src-web/components/core/WindowDragRegion.tsx create mode 100644 src-web/hooks/usePinnedGrpcConnection.ts create mode 100644 src-web/lib/indent.ts create mode 100644 src-web/lib/theme/color.ts delete mode 100644 src-web/lib/theme/theme.test.ts delete mode 100644 src-web/lib/theme/theme.ts diff --git a/package-lock.json b/package-lock.json index 6bd78da0..cfb94dde 100644 --- a/package-lock.json +++ b/package-lock.json @@ -81,7 +81,7 @@ "prettier": "^2.8.4", "react-devtools": "^4.27.2", "tailwindcss": "^3.2.7", - "typescript": "^5.3.3", + "typescript": "^5.4.5", "vite": "^5.0.0", "vite-plugin-svgr": "^4.2.0", "vite-plugin-top-level-await": "^1.4.1", diff --git a/package.json b/package.json index 4d9fb439..96c56421 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "prettier": "^2.8.4", "react-devtools": "^4.27.2", "tailwindcss": "^3.2.7", - "typescript": "^5.3.3", + "typescript": "^5.4.5", "vite": "^5.0.0", "vite-plugin-svgr": "^4.2.0", "vite-plugin-top-level-await": "^1.4.1", diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 6300764d..94b5c0dc 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -42,13 +42,13 @@ "icons/release/icon.icns", "icons/release/icon.ico" ], - "longDescription": "The best cross-platform visual API client", + "longDescription": "A cross-platform desktop app for interacting with REST, GraphQL, and gRPC", "resources": [ "migrations/*", "plugins/*", "protoc-vendored/include/*" ], - "shortDescription": "The best API client", + "shortDescription": "Desktop API client", "targets": [ "deb", "appimage", diff --git a/src-web/components/BinaryFileEditor.tsx b/src-web/components/BinaryFileEditor.tsx index f54a3dea..cec3cc77 100644 --- a/src-web/components/BinaryFileEditor.tsx +++ b/src-web/components/BinaryFileEditor.tsx @@ -46,10 +46,10 @@ export function BinaryFileEditor({ return ( - -
+
{/* Special character to insert ltr text in rtl element without making things wonky */} ‎ {filePath ?? 'Select File'} @@ -64,7 +64,7 @@ export function BinaryFileEditor({
{activeEvent.error && ( -
+
{activeEvent.error}
)} @@ -183,21 +181,21 @@ function EventRow({ className={classNames( 'w-full grid grid-cols-[auto_minmax(0,3fr)_auto] gap-2 items-center text-left', 'px-1.5 py-1 font-mono cursor-default group focus:outline-none rounded', - isActive && '!bg-highlight text-gray-900', - 'text-gray-800 hover:text-gray-900', + isActive && '!bg-background-highlight-secondary !text-fg', + 'text-fg-subtle hover:text-fg', )} > 0) - ? 'text-orange-600' + ? 'text-fg-danger' : eventType === 'connection_end' - ? 'text-green-600' - : 'text-gray-700' + ? 'text-fg-success' + : 'text-fg-subtle' } title={ eventType === 'server_message' @@ -224,7 +222,7 @@ function EventRow({ />
{content.slice(0, 1000)} - {error && ({error})} + {error && ({error})}
{format(createdAt + 'Z', 'HH:mm:ss.SSS')} diff --git a/src-web/components/GrpcConnectionSetupPane.tsx b/src-web/components/GrpcConnectionSetupPane.tsx index ff28dd88..c1b95da5 100644 --- a/src-web/components/GrpcConnectionSetupPane.tsx +++ b/src-web/components/GrpcConnectionSetupPane.tsx @@ -199,14 +199,14 @@ export function GrpcConnectionSetupPane({ label: 'Refresh', type: 'default', key: 'custom', - leftSlot: , + leftSlot: , }, ]} >