diff --git a/src/components/Simulator/screens/SendReceive/ReceivedEther.tsx b/src/components/Simulator/screens/SendReceive/ReceivedEther.tsx index c56d2f29a6a..1f6fecabf52 100644 --- a/src/components/Simulator/screens/SendReceive/ReceivedEther.tsx +++ b/src/components/Simulator/screens/SendReceive/ReceivedEther.tsx @@ -90,6 +90,7 @@ export const ReceivedEther = ({ initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} + data-testid="received-ether-toast" >

diff --git a/src/components/Simulator/screens/SendReceive/SendEther.tsx b/src/components/Simulator/screens/SendReceive/SendEther.tsx index 9b1acd513e2..0f53c24516b 100644 --- a/src/components/Simulator/screens/SendReceive/SendEther.tsx +++ b/src/components/Simulator/screens/SendReceive/SendEther.tsx @@ -1,5 +1,9 @@ import React from "react" -import { Box, Button, Flex, Icon, Text } from "@chakra-ui/react" + +import { Button } from "@/components/ui/buttons/Button" +import { Flex, HStack } from "@/components/ui/flex" + +import { cn } from "@/lib/utils/cn" import { EthTokenIcon } from "../../icons" import { NotificationPopover } from "../../NotificationPopover" @@ -52,27 +56,12 @@ export const SendEther = ({ }).format(chosenAmount) return ( - - - - Send - - How much do you want to send? - - +

+
+

Send

+

How much do you want to send?

+
+ {/* Left side: Displayed send amount */} 0 ? "body.base" : "disabled"} + className={cn( + "font-bold", + chosenAmount > 0 ? "text-body" : "text-disabled" + )} > - +

{formatChosenAmount} - +

{/* Right side */} - + {/* Token selector pill */} - - - - ETH - - + + {/* TODO: remove flags and `size` class when icon is migrated */} + +

ETH

+
{/* Balances */} - - Balance: {usdAmount} - - +

Balance: {usdAmount}

+

<>{ethAmount} ETH - +

- - +
+ {/* Amount buttons */} {AMOUNTS.map((amount, i) => ( ))} - - +
+
) } diff --git a/src/components/Simulator/screens/SendReceive/SendSummary.tsx b/src/components/Simulator/screens/SendReceive/SendSummary.tsx index e00a87532cf..1874aea4a5c 100644 --- a/src/components/Simulator/screens/SendReceive/SendSummary.tsx +++ b/src/components/Simulator/screens/SendReceive/SendSummary.tsx @@ -1,5 +1,8 @@ import React from "react" -import { Box, Flex, Text } from "@chakra-ui/react" + +import { Flex } from "@/components/ui/flex" + +import { cn } from "@/lib/utils/cn" import { ETH_TRANSFER_FEE } from "../../constants" import { getMaxFractionDigitsUsd } from "../../utils" @@ -29,77 +32,52 @@ export const SendSummary = ({ return ( <> {/* Top section */} - - +
+

You are sending - +

0 ? "body.base" : "inherit"} - mb={{ base: 0, md: 2 }} + className={cn( + "flex-1 font-bold md:mb-2", + chosenAmount > 0 ? "text-body" : "text-inherit" + )} > - +

{formatChosenAmount} - +

- +

{formatEth(chosenAmount / ethPrice)} ETH - - +

+
{/* Bottom section */} - - - To - {recipient} - - - Arrival time - est. about 12 seconds - - - Network fees - + +
+

To

+

{recipient}

+
+
+

Arrival time

+

est. about 12 seconds

+
+
+

Network fees

+

{Intl.NumberFormat("en", { maximumFractionDigits: getMaxFractionDigitsUsd(usdFee), style: "currency", currency: "USD", notation: "compact", }).format(usdFee)} - + ( {Intl.NumberFormat("en", { maximumFractionDigits: 6, }).format(ETH_TRANSFER_FEE)}{" "} ETH) - - - + +

+
) diff --git a/src/components/Simulator/screens/SendReceive/Success.tsx b/src/components/Simulator/screens/SendReceive/Success.tsx index cdd3b8a1021..f4477ec79f1 100644 --- a/src/components/Simulator/screens/SendReceive/Success.tsx +++ b/src/components/Simulator/screens/SendReceive/Success.tsx @@ -1,13 +1,17 @@ -import React, { useEffect, useState } from "react" +import { useEffect, useState } from "react" import { AnimatePresence, motion } from "framer-motion" import { PiCheckThin } from "react-icons/pi" -import { Flex, Icon, Spinner, Text } from "@chakra-ui/react" + +import { Flex, VStack } from "@/components/ui/flex" +import { Spinner } from "@/components/ui/spinner" + +import { cn } from "@/lib/utils/cn" import { getMaxFractionDigitsUsd } from "../../utils" import { WalletHome } from "../../WalletHome" import type { TokenBalance } from "../../WalletHome/interfaces" -const ICON_SIZE = "4.5rem" as const +const ICON_SIZE = "text-[4.5rem]" type SuccessProps = { tokenBalances: Array @@ -72,55 +76,50 @@ export const Success = ({ ) : ( - - {txPending ? ( - - - - ) : ( - - - - )} - + + {txPending ? ( - "Sending transaction" + + + ) : ( - - You sent{" "} - - <>{sentEthValue} ETH - {" "} - ({usdValue}) to {recipient} - + + + )} - - +

+ {txPending ? ( + "Sending transaction" + ) : ( + + You sent{" "} + + <>{sentEthValue} ETH + {" "} + ({usdValue}) to {recipient} + + )} +

+ +
)} diff --git a/src/components/Simulator/screens/SendReceive/__stories__/SendReceive.stories.tsx b/src/components/Simulator/screens/SendReceive/__stories__/SendReceive.stories.tsx new file mode 100644 index 00000000000..c3fef1fbaa7 --- /dev/null +++ b/src/components/Simulator/screens/SendReceive/__stories__/SendReceive.stories.tsx @@ -0,0 +1,124 @@ +import type { Meta, StoryObj } from "@storybook/react" +import { expect, fn, waitFor, within } from "@storybook/test" + +import { Phone } from "@/components/Simulator/Phone" +import { Template } from "@/components/Simulator/Template" + +import { SendReceive } from ".." + +const meta = { + title: "Molecules / Display Content / Simulator / SendReceive Screen", + component: SendReceive, + parameters: { + layout: "fullscreen", + }, + args: { + nav: { + progressStepper: fn(), + step: 0, + openPath: fn(), + regressStepper: fn(), + totalSteps: 6, + }, + ctaLabel: "", + }, + decorators: [ + (Story) => ( +
+ +
+ ), + ], +} satisfies Meta + +export default meta + +type Story = StoryObj + +export const ReceiveEther: Story = { + args: { + nav: { + ...meta.args.nav, + step: 1, + }, + ctaLabel: "Share address", + }, +} + +export const ReceivedEther: Story = { + args: { + nav: { + ...meta.args.nav, + step: 2, + }, + }, + play: async ({ canvasElement }) => { + const canvas = within(canvasElement) + + await waitFor( + async () => { + expect(canvas.getByTestId("received-ether-toast")).toBeInTheDocument() + }, + { timeout: 1500 } + ) + }, +} + +export const SendEther: Story = { + args: { + nav: { + ...meta.args.nav, + step: 3, + }, + ctaLabel: "Select recipient", + }, +} + +export const SendFromContacts: Story = { + args: { + nav: { + ...meta.args.nav, + step: 4, + }, + }, +} + +export const SendSummary: Story = { + args: { + nav: { + ...meta.args.nav, + step: 5, + }, + ctaLabel: "Send now", + }, +} + +export const Success: Story = { + args: { + nav: { + ...meta.args.nav, + step: 6, + }, + }, + play: async ({ canvasElement }) => { + const canvas = within(canvasElement) + + await waitFor( + async () => { + const successIcon = canvas.getByTestId("success-icon") + console.log("🚀 ~ successIcon:", successIcon) + await expect(successIcon).toBeInTheDocument() + await expect(successIcon).toHaveStyle({ + transform: "none", + }) + }, + { + timeout: 10000, + } + ) + }, +}