From 52a368bdc88092cac41c926cbceab3d6920c1a13 Mon Sep 17 00:00:00 2001 From: David Rodriguez Date: Wed, 9 Oct 2024 02:28:49 +0200 Subject: [PATCH] chore: First implementation --- crates/web/frontend/package-lock.json | 33 +++++ crates/web/frontend/package.json | 1 + .../frontend/src/components/header/header.tsx | 2 + .../components/import-popup/import-popup.tsx | 8 +- .../request-body-tab.tsx} | 6 +- .../request-headers-datalist.tsx} | 4 +- .../request-headers-tab.tsx} | 10 +- .../settings-sheet/settings-sheet.tsx | 40 +++--- .../components/share-popup/share-popup.tsx | 117 ++++++++++++++++++ .../src/components/ui/radio-group.tsx | 38 ++++++ .../src/components/ui/slider-with-marks.tsx | 50 ++++++++ .../src/components/ui/slider-with-tooltip.tsx | 74 +++++++++++ .../web/frontend/src/components/ui/slider.tsx | 10 +- 13 files changed, 355 insertions(+), 38 deletions(-) rename crates/web/frontend/src/components/{body-tab/body-tab.tsx => request-body-tab/request-body-tab.tsx} (93%) rename crates/web/frontend/src/components/{headers-tab/headers-datalist.tsx => request-headers-tab/request-headers-datalist.tsx} (86%) rename crates/web/frontend/src/components/{headers-tab/headers-tab.tsx => request-headers-tab/request-headers-tab.tsx} (90%) create mode 100644 crates/web/frontend/src/components/share-popup/share-popup.tsx create mode 100644 crates/web/frontend/src/components/ui/radio-group.tsx create mode 100644 crates/web/frontend/src/components/ui/slider-with-marks.tsx create mode 100644 crates/web/frontend/src/components/ui/slider-with-tooltip.tsx diff --git a/crates/web/frontend/package-lock.json b/crates/web/frontend/package-lock.json index f7673017..f875444d 100644 --- a/crates/web/frontend/package-lock.json +++ b/crates/web/frontend/package-lock.json @@ -21,6 +21,7 @@ "@radix-ui/react-hover-card": "^1.1.2", "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-popover": "^1.1.2", + "@radix-ui/react-radio-group": "^1.2.1", "@radix-ui/react-select": "^2.1.2", "@radix-ui/react-separator": "^1.1.0", "@radix-ui/react-slider": "^1.2.1", @@ -1464,6 +1465,38 @@ } } }, + "node_modules/@radix-ui/react-radio-group": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-radio-group/-/react-radio-group-1.2.1.tgz", + "integrity": "sha512-kdbv54g4vfRjja9DNWPMxKvXblzqbpEC8kspEkZ6dVP7kQksGCn+iZHkcCz2nb00+lPdRvxrqy4WrvvV1cNqrQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.0", + "@radix-ui/react-compose-refs": "1.1.0", + "@radix-ui/react-context": "1.1.1", + "@radix-ui/react-direction": "1.1.0", + "@radix-ui/react-presence": "1.1.1", + "@radix-ui/react-primitive": "2.0.0", + "@radix-ui/react-roving-focus": "1.1.0", + "@radix-ui/react-use-controllable-state": "1.1.0", + "@radix-ui/react-use-previous": "1.1.0", + "@radix-ui/react-use-size": "1.1.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-roving-focus": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@radix-ui/react-roving-focus/-/react-roving-focus-1.1.0.tgz", diff --git a/crates/web/frontend/package.json b/crates/web/frontend/package.json index aa23b9f5..2ae25a1f 100644 --- a/crates/web/frontend/package.json +++ b/crates/web/frontend/package.json @@ -24,6 +24,7 @@ "@radix-ui/react-hover-card": "^1.1.2", "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-popover": "^1.1.2", + "@radix-ui/react-radio-group": "^1.2.1", "@radix-ui/react-select": "^2.1.2", "@radix-ui/react-separator": "^1.1.0", "@radix-ui/react-slider": "^1.2.1", diff --git a/crates/web/frontend/src/components/header/header.tsx b/crates/web/frontend/src/components/header/header.tsx index 0a8ad0bb..be762084 100644 --- a/crates/web/frontend/src/components/header/header.tsx +++ b/crates/web/frontend/src/components/header/header.tsx @@ -6,6 +6,7 @@ import { memo } from "react"; import ExamplesSheet from "../examples-sheet/examples-sheet"; import ShortcutPopup from "../shortcut-popup/shortcut-popup"; import StarCount from "../star-count/star-count"; +import SharePopup from "../share-popup/share-popup"; interface Props { className?: string; @@ -28,6 +29,7 @@ const Header = ({ className, onClickExample }: Props) => {
+
diff --git a/crates/web/frontend/src/components/import-popup/import-popup.tsx b/crates/web/frontend/src/components/import-popup/import-popup.tsx index f90cebe8..280f8f30 100644 --- a/crates/web/frontend/src/components/import-popup/import-popup.tsx +++ b/crates/web/frontend/src/components/import-popup/import-popup.tsx @@ -8,8 +8,8 @@ import { fromString } from "@/model/http-method"; import { type LoadingState, notLoading } from "@/model/loading-state"; import { File, FileUp, Trash } from "lucide-react"; import { type ChangeEvent, useCallback, useMemo, useState } from "react"; -import BodyTab from "../body-tab/body-tab"; -import HeadersTab from "../headers-tab/headers-tab"; +import RequestBodyTab from "../request-body-tab/request-body-tab"; +import RequestHeadersTab from "../request-headers-tab/request-headers-tab"; import { Button } from "../ui/button"; import { Dialog, @@ -211,11 +211,11 @@ const ImportPopup = ({ )} - + {httpMethod === "POST" && ( - + )} diff --git a/crates/web/frontend/src/components/body-tab/body-tab.tsx b/crates/web/frontend/src/components/request-body-tab/request-body-tab.tsx similarity index 93% rename from crates/web/frontend/src/components/body-tab/body-tab.tsx rename to crates/web/frontend/src/components/request-body-tab/request-body-tab.tsx index 89e57367..708689bd 100644 --- a/crates/web/frontend/src/components/body-tab/body-tab.tsx +++ b/crates/web/frontend/src/components/request-body-tab/request-body-tab.tsx @@ -7,12 +7,12 @@ import CodeMirror, { type Extension } from "@uiw/react-codemirror"; import { useCallback, useEffect, useMemo, useState } from "react"; import { formatCode, getCodemirrorExtensionsByFileType } from "../editor/editor-utils"; -interface BodyTabProps { +interface RequestBodyTabProps { body: string; setBody: (body: string) => void; } -const BodyTab = ({ body, setBody }: BodyTabProps) => { +const RequestBodyTab = ({ body, setBody }: RequestBodyTabProps) => { const [focused, setFocused] = useState(false); const { settings: { @@ -67,4 +67,4 @@ const BodyTab = ({ body, setBody }: BodyTabProps) => { ); }; -export default BodyTab; +export default RequestBodyTab; diff --git a/crates/web/frontend/src/components/headers-tab/headers-datalist.tsx b/crates/web/frontend/src/components/request-headers-tab/request-headers-datalist.tsx similarity index 86% rename from crates/web/frontend/src/components/headers-tab/headers-datalist.tsx rename to crates/web/frontend/src/components/request-headers-tab/request-headers-datalist.tsx index 43d2c53b..b2ed02a9 100644 --- a/crates/web/frontend/src/components/headers-tab/headers-datalist.tsx +++ b/crates/web/frontend/src/components/request-headers-tab/request-headers-datalist.tsx @@ -2,7 +2,7 @@ interface HeadersDatalistProps { id: string; } -const HeadersDatalist = ({ id }: HeadersDatalistProps) => { +const RequestHeadersDatalist = ({ id }: HeadersDatalistProps) => { return (