From 1dd715e87407d9646bfec9939ad1d9d16aa4f78a Mon Sep 17 00:00:00 2001 From: ioay Date: Sun, 17 Mar 2024 19:19:04 +0100 Subject: [PATCH] Fees popover in transaction modal --- dapp/src/components/GlobalStyles/index.tsx | 3 + .../StakeFormModal/StakeDetails.tsx | 5 +- .../UnstakeFormModal/UnstakeDetails.tsx | 5 +- .../FeesPopover/FeesPopover.tsx | 59 +++++++++++++++++++ .../FeesPopover/FeesPopoverItem.tsx | 27 +++++++++ .../TransactionModal/FeesPopover/index.ts | 1 + .../shared/TransactionDetails/AmountItem.tsx | 11 +++- .../shared/TransactionDetails/index.tsx | 18 ++++-- 8 files changed, 120 insertions(+), 9 deletions(-) create mode 100644 dapp/src/components/TransactionModal/FeesPopover/FeesPopover.tsx create mode 100644 dapp/src/components/TransactionModal/FeesPopover/FeesPopoverItem.tsx create mode 100644 dapp/src/components/TransactionModal/FeesPopover/index.ts diff --git a/dapp/src/components/GlobalStyles/index.tsx b/dapp/src/components/GlobalStyles/index.tsx index e8b11945a..607ecf895 100644 --- a/dapp/src/components/GlobalStyles/index.tsx +++ b/dapp/src/components/GlobalStyles/index.tsx @@ -41,6 +41,9 @@ export default function GlobalStyles() { font-weight: 900; font-style: normal; } + .chakra-popover__content:focus-visible { + box-shadow: none !important; + } `} /> ) diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx index bba5a7c28..542f77921 100644 --- a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx +++ b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx @@ -2,6 +2,7 @@ import React from "react" import { List } from "@chakra-ui/react" import TransactionDetailsAmountItem from "#/components/shared/TransactionDetails/AmountItem" import { useTokenAmountFormValue } from "#/components/shared/TokenAmountForm/TokenAmountFormBase" +import { FeesPopover } from "#/components/TransactionModal/FeesPopover" import { useTransactionDetails } from "#/hooks" import { CurrencyType } from "#/types" @@ -34,7 +35,9 @@ function StakeDetails({ }} /> } from={{ currency, amount: details?.protocolFee, diff --git a/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx b/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx index 850f88561..7a2ec55dd 100644 --- a/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx +++ b/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx @@ -2,6 +2,7 @@ import React from "react" import { List } from "@chakra-ui/react" import TransactionDetailsAmountItem from "#/components/shared/TransactionDetails/AmountItem" import { useTokenAmountFormValue } from "#/components/shared/TokenAmountForm/TokenAmountFormBase" +import { FeesPopover } from "#/components/TransactionModal/FeesPopover" import { useTransactionDetails } from "#/hooks" import { CurrencyType } from "#/types" @@ -22,7 +23,9 @@ function UnstakeDetails({ currency }: { currency: CurrencyType }) { }} /> } from={{ currency, amount: details?.protocolFee, diff --git a/dapp/src/components/TransactionModal/FeesPopover/FeesPopover.tsx b/dapp/src/components/TransactionModal/FeesPopover/FeesPopover.tsx new file mode 100644 index 000000000..1d967729a --- /dev/null +++ b/dapp/src/components/TransactionModal/FeesPopover/FeesPopover.tsx @@ -0,0 +1,59 @@ +import React from "react" +import { Info } from "#/assets/icons" +import { + Popover, + PopoverTrigger, + PopoverContent, + PopoverArrow, + PopoverBody, + Icon, + VStack, +} from "@chakra-ui/react" +import { FeesItemType, FeesPopoverItem } from "./FeesPopoverItem" + +const fees: Array = [ + { + label: "Acre protocol fees", + amount: "100000", + currency: "bitcoin", + }, + { + label: "tBTC bridge fees", + amount: "240000", + currency: "bitcoin", + }, + { + label: "Bitcoin network fees", + amount: "200000", + currency: "bitcoin", + }, +] + +export function FeesPopover() { + return ( + + + + + + + + + {fees.map((fee) => ( + + ))} + + + + + ) +} diff --git a/dapp/src/components/TransactionModal/FeesPopover/FeesPopoverItem.tsx b/dapp/src/components/TransactionModal/FeesPopover/FeesPopoverItem.tsx new file mode 100644 index 000000000..bd4491581 --- /dev/null +++ b/dapp/src/components/TransactionModal/FeesPopover/FeesPopoverItem.tsx @@ -0,0 +1,27 @@ +import React from "react" +import { HStack } from "@chakra-ui/react" +import { + CurrencyBalance, + CurrencyBalanceProps, +} from "#/components/shared/CurrencyBalance" +import { TextSm } from "#/components/shared/Typography" + +export type FeesItemType = CurrencyBalanceProps & { + label: string +} + +export function FeesPopoverItem({ label, amount, ...props }: FeesItemType) { + return ( + + {label} + + + ) +} diff --git a/dapp/src/components/TransactionModal/FeesPopover/index.ts b/dapp/src/components/TransactionModal/FeesPopover/index.ts new file mode 100644 index 000000000..16ee00b3b --- /dev/null +++ b/dapp/src/components/TransactionModal/FeesPopover/index.ts @@ -0,0 +1 @@ +export * from "./FeesPopover" diff --git a/dapp/src/components/shared/TransactionDetails/AmountItem.tsx b/dapp/src/components/shared/TransactionDetails/AmountItem.tsx index cf0c29045..161c920a9 100644 --- a/dapp/src/components/shared/TransactionDetails/AmountItem.tsx +++ b/dapp/src/components/shared/TransactionDetails/AmountItem.tsx @@ -6,15 +6,22 @@ import { CurrencyBalanceWithConversion } from "../CurrencyBalanceWithConversion" type TransactionDetailsAmountItemProps = ComponentProps< typeof CurrencyBalanceWithConversion > & - Pick + Pick function TransactionDetailsAmountItem({ label, + sublabel, + popover, from, to, }: TransactionDetailsAmountItemProps) { return ( - + - - {label} - + + + {label} + {popover} + + {sublabel && {sublabel}} + {value ? {value} : children} )