Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Make Deposit step #21

Merged
merged 27 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4b10dd5
Add Toast component
kpyszkowski Jan 6, 2024
b14b805
Refactor `Toast` component
kpyszkowski Jan 7, 2024
8fdab6c
Restyle `BTCAddressSection` component
kpyszkowski Jan 8, 2024
df3c925
Add `MintDurationTiers` component
kpyszkowski Jan 8, 2024
b0d51cf
Restyle `AddressRow` component
kpyszkowski Jan 8, 2024
b8163b7
Add minor fixes
kpyszkowski Jan 8, 2024
3b1f5ba
Merge branch 'main-cleanup' into ui/make-deposit-step
kpyszkowski Jan 8, 2024
a7d2d77
Merge branch 'main' into ui/make-deposit-step
kpyszkowski Jan 15, 2024
0f0d0ff
Merge branch 'main' into ui/make-deposit-step
kpyszkowski Jan 30, 2024
151e334
Restyle TransactionModal components
kpyszkowski Jan 25, 2024
5e25337
Adjust `GenerateNewDepositAddress` modal styles
kpyszkowski Jan 30, 2024
c27f0c4
Revert "Refactor `Toast` component"
kpyszkowski Jan 30, 2024
4a888f5
Revert "Add Toast component"
kpyszkowski Jan 30, 2024
b5229d8
Minor color adjustments
kpyszkowski Jan 30, 2024
ab7362d
Merge branch 'main' into ui/make-deposit-step
kpyszkowski Feb 2, 2024
dd1d127
Add custom `Copy` icon
kpyszkowski Feb 13, 2024
8eeb36f
Remove unused imports
kpyszkowski Feb 13, 2024
5841b75
Fix close button position when label is not defined
kpyszkowski Feb 13, 2024
b7dabcf
Remove `BridgeContractLink` component
kpyszkowski Feb 13, 2024
8532fbd
Improve responsive styles
kpyszkowski Feb 13, 2024
c1d723a
Change font size
kpyszkowski Feb 13, 2024
ef9178c
Merge branch 'main' into ui/make-deposit-step
kpyszkowski Feb 15, 2024
908d933
Uncomment line
kpyszkowski Feb 15, 2024
c52dc8e
Merge branch 'main' into ui/make-deposit-step
michalsmiarowski Feb 19, 2024
576faa5
Remove `withLinkToBlockExplorer` prop
kpyszkowski Feb 19, 2024
affa52b
Update button label when value is copied
kpyszkowski Feb 19, 2024
25a9c7c
Update whitespace
kpyszkowski Feb 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions src/components/CopyToClipboard/index.tsx
michalsmiarowski marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const CopyToClipboardButton: FC = () => {
>
<IconButton
icon={<IoCopyOutline />}
color="gray.500"
color="hsl(182, 100%, 70%)"
onClick={onCopy}
aria-label={helperText}
variant="ghost"
Expand Down Expand Up @@ -132,22 +132,9 @@ export const CopyAddressToClipboard: FC<CopyAddressToClipboardProps> = ({
copyButtonPosition,
chain,
withFullAddress = false,
withLinkToBlockExplorer = false,
michalsmiarowski marked this conversation as resolved.
Show resolved Hide resolved
...restProps
}) => {
const addressColor = useColorModeValue("brand.500", "brand.100")
const _address = withFullAddress ? address : shortenAddress(address)
const mr = copyButtonPosition === "end" ? "2.5" : undefined
const ml =
!copyButtonPosition || copyButtonPosition === "start" ? "2.5" : undefined

const blockExplorerProps = {
as: ViewInBlockExplorer,
text: _address,
id: address,
type: ExplorerDataType.ADDRESS,
chain,
}

return (
<BaseCopyToClipboard
Expand All @@ -156,14 +143,7 @@ export const CopyAddressToClipboard: FC<CopyAddressToClipboardProps> = ({
textCopiedMsg={textCopiedMsg}
copyButtonPosition={copyButtonPosition}
>
<BodyMd
{...(withLinkToBlockExplorer && blockExplorerProps)}
color={addressColor}
mr={mr}
ml={ml}
textStyle="chain-identifier"
{...restProps}
>
<BodyMd color="white" lineHeight={1.75} mr={6} {...restProps}>
{_address}
</BodyMd>
</BaseCopyToClipboard>
Expand Down
123 changes: 123 additions & 0 deletions src/components/MintDurationTiers/MintDurationTiers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import {
Badge,
BodyMd,
BodySm,
BodyXs,
Box,
Flex,
H5,
HStack,
Icon,
Stack,
VStack,
} from "@threshold-network/components"
michalsmiarowski marked this conversation as resolved.
Show resolved Hide resolved
import { FC } from "react"
import { getRangeSign } from "../../utils/getRangeSign"
import { getDurationByNumberOfConfirmations } from "../../utils/tBTC"
import { StackProps } from "@threshold-network/components"
import { ComponentPropsWithoutRef } from "react"
import { RangeOperatorType, CurrencyType } from "../../types"
import { useThreshold } from "../../contexts/ThresholdContext"
import { HiClock as ClockIcon } from "react-icons/hi"

type BaseProps = ComponentPropsWithoutRef<"li"> & StackProps
type MintDurationTiersItemProps = {
amount: number
currency: CurrencyType
rangeOperator: RangeOperatorType
}

interface MintDurationTiersProps extends BaseProps {
items: MintDurationTiersItemProps[]
}

const MintDurationTiers: FC<MintDurationTiersProps> = ({
items,
...restProps
}) => {
const {
tbtc: {
minimumNumberOfConfirmationsNeeded: getNumberOfConfirmationsByAmount,
},
} = useThreshold()

return (
<VStack spacing={2} align="start" {...restProps}>
<BodySm fontWeight="medium" color="hsl(181, 100%, 70%)" lineHeight={1.5}>
Minting Time Est.
</BodySm>
<Stack
w="full"
direction={{
base: "column",
sm: "row",
}}
spacing={{
base: 3,
md: 4,
}}
>
{items.map(({ amount, rangeOperator, currency }, index) => {
const correctedAmount =
amount + (rangeOperator.includes("greater") ? 0.01 : -0.01)
// The amount is corrected by adding or subtracting 0.01 to the given
// amount depending on the range operator. This is done to avoid
// floating-point errors when comparing BigNumber values.
const safeAmount = Number.isSafeInteger(correctedAmount)
? correctedAmount
: Math.floor((correctedAmount as number) * 1e8)
// Only safe integers (not floating-point numbers) can be transformed to
// BigNumber. Converting the given amount to a safe integer if it is not
// already a safe integer. If the amount is already a safe integer, it
// is returned as is.
const confirmations = getNumberOfConfirmationsByAmount(safeAmount)
const durationInMinutes =
getDurationByNumberOfConfirmations(confirmations)
// Round up the minutes to the nearest half-hour
const hours = (Math.round(durationInMinutes / 30) * 30) / 60
const formattedAmount = amount.toFixed(2)

const hoursSuffix = hours === 1 ? "hour" : "hours"
const confirmationsSuffix =
confirmations === 1 ? "confirmation" : "confirmations"
const rangeSign = getRangeSign(rangeOperator)
return (
<VStack
key={index}
align="start"
spacing={6}
flexFlow={{ sm: "column" }}
flex="1"
rounded="2xl"
boxShadow="2xl"
bg="#0D0D0D"
border="1px solid hsla(0, 0%, 20%, 40%)"
p={4}
>
<VStack spacing={0} align="start" w="full">
<BodyMd lineHeight={5} fontWeight="medium" color="white">
{rangeSign} {formattedAmount} BTC
</BodyMd>
<BodyMd color="hsla(0, 0%, 100%, 50%)" whiteSpace="nowrap">
<Box as="span" color="hsl(151, 100%, 70%)">
+ {confirmations}
</Box>
<Box as="span" lineHeight={5}>
&nbsp;{confirmationsSuffix}
</Box>
</BodyMd>
</VStack>
<Flex as={Badge} align="center">
{/* TODO: Adjust styles when Badge changes are merged. */}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you tell me in wchich PR the Badge changes are addressed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it's LabeledBadge introduced in this PR.
I will complete this TODO in separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will leave this conversation open then

<Icon as={ClockIcon} mr={2} w={3.5} h={3.5} />
Est. {hours} {hoursSuffix}
</Flex>
</VStack>
)
})}
</Stack>
</VStack>
)
}

export default MintDurationTiers
1 change: 1 addition & 0 deletions src/components/MintDurationTiers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as MintDurationTiers } from "./MintDurationTiers"
38 changes: 9 additions & 29 deletions src/components/Modal/SelectWalletModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,14 @@ const SelectWalletModal: FC<BaseModalProps> = () => {
setWalletToConnect(walletType)
}

return (
<>
<ModalHeader
as={Flex}
align="center"
justify="space-between"
p={6}
mb={4}
>
<Text as="h2" fontSize="xl" lineHeight={6} fontWeight="medium">
Connect a Wallet
</Text>
<ModalCloseButton position="relative" inset={0} />
</ModalHeader>

{walletToConnect === null ? (
<InitialWalletSelection
walletOptions={walletOptions}
onSelect={onClick}
/>
) : (
<ConnectWallet
walletType={walletToConnect}
goBack={goBack}
onClose={closeModal}
/>
)}
</>
return walletToConnect === null ? (
<InitialWalletSelection walletOptions={walletOptions} onSelect={onClick} />
) : (
<ConnectWallet
walletType={walletToConnect}
goBack={goBack}
onClose={closeModal}
/>
)
}

Expand All @@ -136,4 +116,4 @@ const ConnectWallet: FC<{
}
}

export default withBaseModal(SelectWalletModal)
export default withBaseModal(SelectWalletModal, "Connect a Wallet")
Loading
Loading