From 254a952716de71a08fe5d49d13af88ed7d2620e0 Mon Sep 17 00:00:00 2001 From: tylerapfledderer Date: Fri, 7 Feb 2025 13:23:49 -0500 Subject: [PATCH 1/6] feat(Simulator/screens/SendReceive): create stories --- .../screens/SendReceive/ReceivedEther.tsx | 1 + .../Simulator/screens/SendReceive/Success.tsx | 2 +- .../__stories__/SendReceive.stories.tsx | 114 ++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 src/components/Simulator/screens/SendReceive/__stories__/SendReceive.stories.tsx 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/Success.tsx b/src/components/Simulator/screens/SendReceive/Success.tsx index cdd3b8a1021..b266f99a711 100644 --- a/src/components/Simulator/screens/SendReceive/Success.tsx +++ b/src/components/Simulator/screens/SendReceive/Success.tsx @@ -111,7 +111,7 @@ export const Success = ({ {txPending ? ( "Sending transaction" ) : ( - + You sent{" "} <>{sentEthValue} ETH 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..bdacb83444f --- /dev/null +++ b/src/components/Simulator/screens/SendReceive/__stories__/SendReceive.stories.tsx @@ -0,0 +1,114 @@ +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 () => { + expect(canvas.getByTestId("success-message")).toBeInTheDocument() + }) + }, +} From 9a12c5de7e70603176281d07fd852b21afd7fdd6 Mon Sep 17 00:00:00 2001 From: tylerapfledderer Date: Fri, 7 Feb 2025 14:13:04 -0500 Subject: [PATCH 2/6] feat(Simulator/screens/SendEther): migrate to Tailwind --- .../screens/SendReceive/SendEther.tsx | 98 +++++++------------ 1 file changed, 34 insertions(+), 64 deletions(-) diff --git a/src/components/Simulator/screens/SendReceive/SendEther.tsx b/src/components/Simulator/screens/SendReceive/SendEther.tsx index 9b1acd513e2..3c8d5c8f8bd 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( + "flex-1 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) => ( ))} - - +
+
) } From dbd2f152ae67d2672521edf545553ff136883400 Mon Sep 17 00:00:00 2001 From: tylerapfledderer Date: Sat, 8 Feb 2025 10:50:28 -0500 Subject: [PATCH 3/6] feat(Simulator/screens/Success): migrate to Tailwind --- .../Simulator/screens/SendReceive/Success.tsx | 94 +++++++++---------- 1 file changed, 46 insertions(+), 48 deletions(-) diff --git a/src/components/Simulator/screens/SendReceive/Success.tsx b/src/components/Simulator/screens/SendReceive/Success.tsx index b266f99a711..3dd3dace824 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 = "size-4.5rem" type SuccessProps = { tokenBalances: Array @@ -72,55 +76,49 @@ export const Success = ({ ) : ( - - {txPending ? ( - - - - ) : ( - - - - )} - + + {txPending ? ( - "Sending transaction" + + + ) : ( - - You sent{" "} - - <>{sentEthValue} ETH - {" "} - ({usdValue}) to {recipient} - + + + )} - - +

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

+ +
)} From 14b600460cee81ca772faddb1624f68633973a93 Mon Sep 17 00:00:00 2001 From: tylerapfledderer Date: Sat, 8 Feb 2025 12:14:18 -0500 Subject: [PATCH 4/6] fix(Simulator/screens/Success): set font size for icons --- .../Simulator/screens/SendReceive/Success.tsx | 5 +++-- .../__stories__/SendReceive.stories.tsx | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/components/Simulator/screens/SendReceive/Success.tsx b/src/components/Simulator/screens/SendReceive/Success.tsx index 3dd3dace824..f4477ec79f1 100644 --- a/src/components/Simulator/screens/SendReceive/Success.tsx +++ b/src/components/Simulator/screens/SendReceive/Success.tsx @@ -11,7 +11,7 @@ import { getMaxFractionDigitsUsd } from "../../utils" import { WalletHome } from "../../WalletHome" import type { TokenBalance } from "../../WalletHome/interfaces" -const ICON_SIZE = "size-4.5rem" +const ICON_SIZE = "text-[4.5rem]" type SuccessProps = { tokenBalances: Array @@ -100,6 +100,7 @@ export const Success = ({ initial={{ scale: 0 }} animate={{ scale: 1 }} transition={{ type: "spring", delay: 0.25 }} + data-testid="success-icon" > @@ -108,7 +109,7 @@ export const Success = ({ {txPending ? ( "Sending transaction" ) : ( - + You sent{" "} <>{sentEthValue} ETH diff --git a/src/components/Simulator/screens/SendReceive/__stories__/SendReceive.stories.tsx b/src/components/Simulator/screens/SendReceive/__stories__/SendReceive.stories.tsx index bdacb83444f..c3fef1fbaa7 100644 --- a/src/components/Simulator/screens/SendReceive/__stories__/SendReceive.stories.tsx +++ b/src/components/Simulator/screens/SendReceive/__stories__/SendReceive.stories.tsx @@ -107,8 +107,18 @@ export const Success: Story = { play: async ({ canvasElement }) => { const canvas = within(canvasElement) - await waitFor(async () => { - expect(canvas.getByTestId("success-message")).toBeInTheDocument() - }) + 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, + } + ) }, } From 824cb60450ba53ba6711925b8b48182555b05db8 Mon Sep 17 00:00:00 2001 From: tylerapfledderer Date: Sat, 8 Feb 2025 14:39:12 -0500 Subject: [PATCH 5/6] feat(Simulator/screens/SendSummary): migrate to Tailwind --- .../screens/SendReceive/SendSummary.tsx | 86 +++++++------------ 1 file changed, 32 insertions(+), 54 deletions(-) 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) - - - + +

+
) From dc76cb7b7fb385f9f9c11d6789fd86cd5b806712 Mon Sep 17 00:00:00 2001 From: Pablo Date: Tue, 11 Feb 2025 10:36:16 +0100 Subject: [PATCH 6/6] set space-between in send ether screen --- src/components/Simulator/screens/SendReceive/SendEther.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Simulator/screens/SendReceive/SendEther.tsx b/src/components/Simulator/screens/SendReceive/SendEther.tsx index 3c8d5c8f8bd..0f53c24516b 100644 --- a/src/components/Simulator/screens/SendReceive/SendEther.tsx +++ b/src/components/Simulator/screens/SendReceive/SendEther.tsx @@ -61,7 +61,7 @@ export const SendEther = ({

Send

How much do you want to send?

- + {/* Left side: Displayed send amount */} 0 ? "text-body" : "text-disabled" )} >