From 34fa6becdd115ad917bf6156a624910722a1e478 Mon Sep 17 00:00:00 2001 From: sehyunc <41171808+sehyunc@users.noreply.github.com> Date: Sat, 21 Sep 2024 13:52:49 -0700 Subject: [PATCH] mobile: convert drawers to full screen dialogs --- .../order-details/order-details-sheet.tsx | 32 ++-- .../mobile/new-order-stepper.tsx | 16 +- .../order-stepper/mobile/steps/confirm.tsx | 17 +- .../order-stepper/mobile/steps/default.tsx | 22 +-- .../mobile/steps/success-without-savings.tsx | 27 ++- .../order-stepper/mobile/steps/success.tsx | 159 ------------------ components/dialogs/sign-in-dialog.tsx | 57 +++---- components/dialogs/token-select-dialog.tsx | 36 ++-- .../dialogs/transfer/transfer-dialog.tsx | 90 +++++----- 9 files changed, 153 insertions(+), 303 deletions(-) delete mode 100644 components/dialogs/order-stepper/mobile/steps/success.tsx diff --git a/app/trade/[base]/components/order-details/order-details-sheet.tsx b/app/trade/[base]/components/order-details/order-details-sheet.tsx index 5bc4e473..8503a17c 100644 --- a/app/trade/[base]/components/order-details/order-details-sheet.tsx +++ b/app/trade/[base]/components/order-details/order-details-sheet.tsx @@ -5,13 +5,13 @@ import { DetailsContent } from "@/app/trade/[base]/components/order-details/deta import { EmptyContent } from "@/app/trade/[base]/components/order-details/empty-content" import { - Drawer, - DrawerContent, - DrawerDescription, - DrawerHeader, - DrawerTitle, - DrawerTrigger, -} from "@/components/ui/drawer" + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog" import { Sheet, SheetContent, @@ -58,15 +58,15 @@ export function OrderDetailsSheet({ ) } return ( - - {children} - + + {children} +
- - Order Details - View order details - + + Order Details + View order details + {order.fills.length ? ( @@ -74,7 +74,7 @@ export function OrderDetailsSheet({ )}
-
-
+ + ) } diff --git a/components/dialogs/order-stepper/mobile/new-order-stepper.tsx b/components/dialogs/order-stepper/mobile/new-order-stepper.tsx index bbd15f20..2692baeb 100644 --- a/components/dialogs/order-stepper/mobile/new-order-stepper.tsx +++ b/components/dialogs/order-stepper/mobile/new-order-stepper.tsx @@ -4,8 +4,7 @@ import { NewOrderConfirmationProps } from "@/components/dialogs/order-stepper/de import { ConfirmStep } from "@/components/dialogs/order-stepper/mobile/steps/confirm" import { DefaultStep } from "@/components/dialogs/order-stepper/mobile/steps/default" import { SuccessStepWithoutSavings } from "@/components/dialogs/order-stepper/mobile/steps/success-without-savings" -import { Drawer, DrawerContent, DrawerTrigger } from "@/components/ui/drawer" -import { ScrollArea } from "@/components/ui/scroll-area" +import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog" export function NewOrderStepperInner({ children, @@ -23,17 +22,16 @@ export function NewOrderStepperInner({ } return ( - { setLockedFormValues(null) setStep(Step.DEFAULT) setTaskId("") }} > - {children} - -
+ {children} + +
{step === Step.DEFAULT && ( }
- - +
+ ) } diff --git a/components/dialogs/order-stepper/mobile/steps/confirm.tsx b/components/dialogs/order-stepper/mobile/steps/confirm.tsx index a5565311..363ea460 100644 --- a/components/dialogs/order-stepper/mobile/steps/confirm.tsx +++ b/components/dialogs/order-stepper/mobile/steps/confirm.tsx @@ -7,7 +7,7 @@ import { NewOrderConfirmationProps } from "@/components/dialogs/order-stepper/de import { ConfirmOrderDisplay } from "@/components/dialogs/order-stepper/desktop/steps/default" import { useStepper } from "@/components/dialogs/order-stepper/mobile/new-order-stepper" import { Button } from "@/components/ui/button" -import { DrawerFooter, DrawerHeader, DrawerTitle } from "@/components/ui/drawer" +import { DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { ScrollArea } from "@/components/ui/scroll-area" import { usePrepareCreateOrder } from "@/hooks/use-prepare-create-order" @@ -52,18 +52,19 @@ export function ConfirmStep(props: NewOrderConfirmationProps) { return ( <> - - Review Order - + + Review Order + -
+
- + - + ) } diff --git a/components/dialogs/order-stepper/mobile/steps/default.tsx b/components/dialogs/order-stepper/mobile/steps/default.tsx index 8c157acb..7e4001d1 100644 --- a/components/dialogs/order-stepper/mobile/steps/default.tsx +++ b/components/dialogs/order-stepper/mobile/steps/default.tsx @@ -4,14 +4,11 @@ import { AssetsSection } from "@/app/trade/[base]/components/new-order/assets-se import { NewOrderForm } from "@/app/trade/[base]/components/new-order/new-order-form" import { NewOrderConfirmationProps } from "@/components/dialogs/order-stepper/desktop/new-order-stepper" -import { Button } from "@/components/ui/button" import { - DrawerClose, - DrawerDescription, - DrawerFooter, - DrawerHeader, - DrawerTitle, -} from "@/components/ui/drawer" + DialogDescription, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog" import { Separator } from "@/components/ui/separator" export function DefaultStep(props: { @@ -21,13 +18,13 @@ export function DefaultStep(props: { }) { return ( <> - + - Place Order - Place a new order. + Place Order + Place a new order. - -
+ +
- ) } diff --git a/components/dialogs/order-stepper/mobile/steps/success-without-savings.tsx b/components/dialogs/order-stepper/mobile/steps/success-without-savings.tsx index b68acfb9..040a8f73 100644 --- a/components/dialogs/order-stepper/mobile/steps/success-without-savings.tsx +++ b/components/dialogs/order-stepper/mobile/steps/success-without-savings.tsx @@ -8,8 +8,13 @@ import { useStepper } from "@/components/dialogs/order-stepper/mobile/new-order- import { DidYouKnowContent } from "@/components/did-you-know-content" import { OrderStatusDisplay } from "@/components/order-status-display" import { Button } from "@/components/ui/button" -import { DialogDescription, DialogTitle } from "@/components/ui/dialog" -import { DrawerClose, DrawerFooter, DrawerHeader } from "@/components/ui/drawer" +import { + DialogClose, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog" const states: TaskState[] = [ "Proving", @@ -53,15 +58,15 @@ export function SuccessStepWithoutSavings() { return ( <> - - + + {Icon} {title} Your order has been placed. - +
- + + + + + ) } diff --git a/components/dialogs/order-stepper/mobile/steps/success.tsx b/components/dialogs/order-stepper/mobile/steps/success.tsx deleted file mode 100644 index 74cc21bb..00000000 --- a/components/dialogs/order-stepper/mobile/steps/success.tsx +++ /dev/null @@ -1,159 +0,0 @@ -import * as React from "react" - -import { VisuallyHidden } from "@radix-ui/react-visually-hidden" -import { useTaskHistoryWebSocket } from "@renegade-fi/react" -import { Repeat } from "lucide-react" - -import { - NewOrderConfirmationProps, - useStepper, -} from "@/components/dialogs/order-stepper/desktop/new-order-stepper" -import { GlowText } from "@/components/glow-text" -import { Button } from "@/components/ui/button" -import { Checkbox } from "@/components/ui/checkbox" -import { - DialogClose, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, -} from "@/components/ui/dialog" -import { - DrawerClose, - DrawerFooter, - DrawerHeader, - DrawerTitle, -} from "@/components/ui/drawer" -import { ScrollArea } from "@/components/ui/scroll-area" -import { Spinner } from "@/components/ui/spinner" - -import { useMediaQuery } from "@/hooks/use-media-query" -import { formatCurrency } from "@/lib/format" - -export function SuccessStep(props: NewOrderConfirmationProps) { - const isDesktop = useMediaQuery("(min-width: 1024px)") - const { taskId } = useStepper() - const [status, setStatus] = React.useState<"pending" | "success" | "error">( - "pending", - ) - - useTaskHistoryWebSocket({ - onUpdate(task) { - if (task.id === taskId) { - if (task.state === "Completed") { - setStatus("success") - } else if (task.state === "Failed") { - setStatus("error") - } - } - }, - }) - - const title = - status === "pending" - ? "Placing Order" - : status === "success" - ? "Order Placed" - : "Failed to Place Order" - const description = - status === "pending" - ? "Your order is being placed." - : status === "success" - ? "Your order has been placed." - : "Your order has failed." - - if (isDesktop) { - return ( - <> - - - {title} - {status === "pending" && } - - - {description} - - -
- -
- - - - - - - ) - } - - return ( - <> - - {title} - - -
- -
-
- - - - - - - ) -} - -function OrderSuccessSection({ predictedSavings }: NewOrderConfirmationProps) { - const savingsLabel = predictedSavings - ? formatCurrency(predictedSavings) - : "--" - return ( - <> -
-
You're estimated to save
- -
when your order fills at the realtime Binance midpoint price.
-
-
-
- Did you know? - -
-
All trades are pre-trade and post-trade private.
-
-
- - -
- - ) -} diff --git a/components/dialogs/sign-in-dialog.tsx b/components/dialogs/sign-in-dialog.tsx index 277605a6..65f45985 100644 --- a/components/dialogs/sign-in-dialog.tsx +++ b/components/dialogs/sign-in-dialog.tsx @@ -23,14 +23,6 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog" -import { - Drawer, - DrawerContent, - DrawerDescription, - DrawerFooter, - DrawerHeader, - DrawerTitle, -} from "@/components/ui/drawer" import { useMediaQuery } from "@/hooks/use-media-query" import { STORAGE_REMEMBER_ME } from "@/lib/constants/storage" @@ -186,32 +178,35 @@ export function SignInDialog({ } return ( - - - - Unlock your Wallet - - To trade on Renegade, we require a one-time signature to create or - find your wallet on-chain. - - - - - - - - + +
+ + Unlock your Wallet + + To trade on Renegade, we require a one-time signature to create or + find your wallet on-chain. + + + + + + +
+
+ ) } diff --git a/components/dialogs/token-select-dialog.tsx b/components/dialogs/token-select-dialog.tsx index 8e599415..bae10c85 100644 --- a/components/dialogs/token-select-dialog.tsx +++ b/components/dialogs/token-select-dialog.tsx @@ -17,14 +17,6 @@ import { DialogTitle, DialogTrigger, } from "@/components/ui/dialog" -import { - Drawer, - DrawerContent, - DrawerDescription, - DrawerHeader, - DrawerTitle, - DrawerTrigger, -} from "@/components/ui/drawer" import { Input } from "@/components/ui/input" import { ScrollArea } from "@/components/ui/scroll-area" @@ -77,23 +69,29 @@ export function TokenSelectDialog({ } return ( - - {children} - - - Select Token - + {children} + { + e.preventDefault() + }} + > + + Select Token + setSearchTerm(e.target.value)} /> - - - + + + setOpen(false)} /> - - + + ) } diff --git a/components/dialogs/transfer/transfer-dialog.tsx b/components/dialogs/transfer/transfer-dialog.tsx index 46532eaf..b1ef73b7 100644 --- a/components/dialogs/transfer/transfer-dialog.tsx +++ b/components/dialogs/transfer/transfer-dialog.tsx @@ -19,6 +19,7 @@ import { NumberInput } from "@/components/number-input" import { Button } from "@/components/ui/button" import { Dialog, + DialogClose, DialogContent, DialogDescription, DialogFooter, @@ -26,16 +27,6 @@ import { DialogTitle, DialogTrigger, } from "@/components/ui/dialog" -import { - Drawer, - DrawerClose, - DrawerContent, - DrawerDescription, - DrawerFooter, - DrawerHeader, - DrawerTitle, - DrawerTrigger, -} from "@/components/ui/drawer" import { Form, FormControl, @@ -178,17 +169,31 @@ export function TransferDialog({ } return ( - - {children} - - -
+ {children} + +
+ + + + {direction === ExternalTransferDirection.Deposit + ? "Deposit" + : "Withdraw"} + + + {direction === ExternalTransferDirection.Deposit + ? "Deposit tokens into Renegade" + : "Withdraw tokens from Renegade"} + + + +
- - - {direction === ExternalTransferDirection.Deposit - ? "Deposit" - : "Withdraw"} - - - {direction === ExternalTransferDirection.Deposit - ? "Deposit tokens into Renegade" - : "Withdraw tokens from Renegade"} - - - - setOpen(false)} - /> - - + setOpen(false)} + /> +
+
+ ) } @@ -464,7 +457,10 @@ function TransferForm({ return (
- +
) : ( - + + + + - + )}