|
1 |
| -import React from "react" |
2 |
| -import { |
3 |
| - type As, |
4 |
| - Box, |
5 |
| - Grid, |
6 |
| - Icon, |
7 |
| - Text, |
8 |
| - type TextProps, |
9 |
| -} from "@chakra-ui/react" |
| 1 | +import { type ReactNode } from "react" |
| 2 | +import type { IconType } from "react-icons/lib" |
| 3 | + |
| 4 | +import { Button } from "@/components/ui/buttons/Button" |
| 5 | + |
| 6 | +import { cn } from "@/lib/utils/cn" |
10 | 7 |
|
11 |
| -import { Button } from "../../Buttons" |
12 | 8 | import { ClickAnimation } from "../ClickAnimation"
|
13 | 9 | import { PulseAnimation } from "../PulseAnimation"
|
14 | 10 |
|
15 |
| -type SendReceiveButtonProps = Pick<TextProps, "children"> & { |
16 |
| - icon: As |
| 11 | +type SendReceiveButtonProps = { |
| 12 | + icon: IconType |
17 | 13 | isHighlighted: boolean
|
18 | 14 | isDisabled: boolean
|
19 | 15 | onClick?: () => void
|
20 | 16 | isAnimated?: boolean
|
| 17 | + children: ReactNode |
21 | 18 | }
|
22 | 19 |
|
23 | 20 | export const SendReceiveButton = ({
|
24 | 21 | children,
|
25 |
| - icon, |
| 22 | + icon: Icon, |
26 | 23 | isHighlighted,
|
27 | 24 | isDisabled,
|
28 | 25 | onClick,
|
29 | 26 | isAnimated,
|
30 | 27 | }: SendReceiveButtonProps) => (
|
31 | 28 | <Button
|
32 | 29 | variant="ghost"
|
33 |
| - display="flex" |
34 |
| - flexDirection="column" |
35 |
| - alignItems="center" |
| 30 | + className="group flex-col items-center gap-4" |
36 | 31 | data-group
|
37 |
| - isDisabled={isDisabled} |
| 32 | + disabled={isDisabled} |
38 | 33 | onClick={onClick}
|
39 |
| - gap={4} |
40 | 34 | >
|
41 |
| - <Grid |
42 |
| - bg="primary.base" |
43 |
| - borderRadius="full" |
44 |
| - placeItems="center" |
45 |
| - w={{ base: 10, md: 16 }} |
46 |
| - aspectRatio={1} |
47 |
| - _groupHover={{ bg: "primary.hover" }} |
48 |
| - _groupDisabled={{ |
49 |
| - background: isHighlighted ? "primary.base" : "body.light", |
50 |
| - }} |
51 |
| - position="relative" |
| 35 | + <div |
| 36 | + className={cn( |
| 37 | + "relative grid aspect-square w-10 place-items-center rounded-full bg-primary group-hover:bg-primary-hover md:w-16", |
| 38 | + isHighlighted |
| 39 | + ? "group-disabled:bg-primary" |
| 40 | + : "group-disabled:bg-body-light" |
| 41 | + )} |
52 | 42 | >
|
53 | 43 | {!isDisabled && isAnimated && <PulseAnimation type="circle" />}
|
54 |
| - <Icon |
55 |
| - as={icon} |
56 |
| - w={{ base: 4, md: 6 }} |
57 |
| - h={{ base: 4, md: 6 }} |
58 |
| - color="background.base" |
59 |
| - /> |
60 |
| - </Grid> |
61 |
| - <Box position="relative"> |
62 |
| - <Text |
63 |
| - fontWeight="bold" |
64 |
| - color="primary.base" |
65 |
| - textAlign="center" |
66 |
| - m={0} |
67 |
| - _groupHover={{ color: "primary.hover" }} |
68 |
| - _groupDisabled={{ |
69 |
| - color: isHighlighted ? "primary.base" : "body.medium", |
70 |
| - }} |
71 |
| - position="relative" |
| 44 | + {/* TODO: Remove important flags from class utils when simulator icons are migrated to tailwind */} |
| 45 | + <Icon className="!size-4 !text-background md:!size-6" /> |
| 46 | + </div> |
| 47 | + <div className="relative"> |
| 48 | + <p |
| 49 | + className={cn( |
| 50 | + "relative text-center font-bold text-primary group-hover:text-primary-hover", |
| 51 | + isHighlighted |
| 52 | + ? "group-disabled:text-primary" |
| 53 | + : "group-disabled:text-body-medium" |
| 54 | + )} |
72 | 55 | >
|
73 | 56 | {children}
|
74 |
| - </Text> |
| 57 | + </p> |
75 | 58 | {!isDisabled && isAnimated && (
|
76 | 59 | <ClickAnimation below>click!</ClickAnimation>
|
77 | 60 | )}
|
78 |
| - </Box> |
| 61 | + </div> |
79 | 62 | </Button>
|
80 | 63 | )
|
0 commit comments