|
1 |
| -import React, { useEffect, useState } from "react" |
| 1 | +import { useEffect, useState } from "react" |
2 | 2 | import { AnimatePresence, motion } from "framer-motion"
|
3 | 3 | import { PiCheckThin } from "react-icons/pi"
|
4 |
| -import { Flex, Icon, Spinner, Text } from "@chakra-ui/react" |
| 4 | + |
| 5 | +import { Flex, VStack } from "@/components/ui/flex" |
| 6 | +import { Spinner } from "@/components/ui/spinner" |
| 7 | + |
| 8 | +import { cn } from "@/lib/utils/cn" |
5 | 9 |
|
6 | 10 | import { getMaxFractionDigitsUsd } from "../../utils"
|
7 | 11 | import { WalletHome } from "../../WalletHome"
|
8 | 12 | import type { TokenBalance } from "../../WalletHome/interfaces"
|
9 | 13 |
|
10 |
| -const ICON_SIZE = "4.5rem" as const |
| 14 | +const ICON_SIZE = "size-4.5rem" |
11 | 15 |
|
12 | 16 | type SuccessProps = {
|
13 | 17 | tokenBalances: Array<TokenBalance>
|
@@ -72,55 +76,49 @@ export const Success = ({
|
72 | 76 | </motion.div>
|
73 | 77 | ) : (
|
74 | 78 | <Flex
|
75 |
| - animate={{ opacity: [0, 1] }} |
76 |
| - exit={{ opacity: 0 }} |
77 |
| - key="success-fade-out" |
78 |
| - as={motion.div} |
79 |
| - justify="center" |
80 |
| - h="full" |
81 |
| - bg="background.highlight" |
82 |
| - pt={{ base: 24, md: 0 }} |
83 |
| - alignItems={{ base: "start", md: "center" }} |
| 79 | + className="h-full justify-center bg-background-highlight max-md:pt-24 md:items-center" |
| 80 | + asChild |
84 | 81 | >
|
85 |
| - <Flex direction="column" alignItems="center" pt={8} gap={4}> |
86 |
| - {txPending ? ( |
87 |
| - <motion.div |
88 |
| - key="spinner" |
89 |
| - initial={{ opacity: 0 }} |
90 |
| - animate={{ opacity: 1 }} |
91 |
| - transition={{ duration: 0.5 }} |
92 |
| - > |
93 |
| - <Spinner w={ICON_SIZE} h={ICON_SIZE} /> |
94 |
| - </motion.div> |
95 |
| - ) : ( |
96 |
| - <motion.div |
97 |
| - key="checkmark" |
98 |
| - initial={{ scale: 0 }} |
99 |
| - animate={{ scale: 1 }} |
100 |
| - transition={{ type: "spring", delay: 0.25 }} |
101 |
| - > |
102 |
| - <Icon |
103 |
| - as={PiCheckThin} |
104 |
| - w={ICON_SIZE} |
105 |
| - h={ICON_SIZE} |
106 |
| - transform="rotate(-10deg)" |
107 |
| - /> |
108 |
| - </motion.div> |
109 |
| - )} |
110 |
| - <Text textAlign="center" px={{ base: 4, md: 8 }}> |
| 82 | + <motion.div |
| 83 | + animate={{ opacity: [0, 1] }} |
| 84 | + exit={{ opacity: 0 }} |
| 85 | + key="success-fade-out" |
| 86 | + > |
| 87 | + <VStack className="gap-4 pt-8"> |
111 | 88 | {txPending ? (
|
112 |
| - "Sending transaction" |
| 89 | + <motion.div |
| 90 | + key="spinner" |
| 91 | + initial={{ opacity: 0 }} |
| 92 | + animate={{ opacity: 1 }} |
| 93 | + transition={{ duration: 0.5 }} |
| 94 | + > |
| 95 | + <Spinner className={ICON_SIZE} /> |
| 96 | + </motion.div> |
113 | 97 | ) : (
|
114 |
| - <Text as="span" data-testid="success-message"> |
115 |
| - You sent{" "} |
116 |
| - <strong> |
117 |
| - <>{sentEthValue} ETH</> |
118 |
| - </strong>{" "} |
119 |
| - ({usdValue}) to <strong>{recipient}</strong> |
120 |
| - </Text> |
| 98 | + <motion.div |
| 99 | + key="checkmark" |
| 100 | + initial={{ scale: 0 }} |
| 101 | + animate={{ scale: 1 }} |
| 102 | + transition={{ type: "spring", delay: 0.25 }} |
| 103 | + > |
| 104 | + <PiCheckThin className={cn(ICON_SIZE, "-rotate-[10deg]")} /> |
| 105 | + </motion.div> |
121 | 106 | )}
|
122 |
| - </Text> |
123 |
| - </Flex> |
| 107 | + <p className="px-4 text-center md:px-8"> |
| 108 | + {txPending ? ( |
| 109 | + "Sending transaction" |
| 110 | + ) : ( |
| 111 | + <span data-testid="success-message"> |
| 112 | + You sent{" "} |
| 113 | + <strong> |
| 114 | + <>{sentEthValue} ETH</> |
| 115 | + </strong>{" "} |
| 116 | + ({usdValue}) to <strong>{recipient}</strong> |
| 117 | + </span> |
| 118 | + )} |
| 119 | + </p> |
| 120 | + </VStack> |
| 121 | + </motion.div> |
124 | 122 | </Flex>
|
125 | 123 | )}
|
126 | 124 | </AnimatePresence>
|
|
0 commit comments