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

dApp: Tooltip updates #825

Open
wants to merge 6 commits into
base: ledger-live-updates
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 18 additions & 2 deletions dapp/src/components/shared/CurrencyBalance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
useMultiStyleConfig,
TextProps,
ResponsiveValue,
Tooltip,
} from "@chakra-ui/react"
import {
bigIntToUserAmount,
formatTokenAmount,
getCurrencyByType,
numberToLocaleString,
Expand All @@ -29,6 +31,7 @@ export type CurrencyBalanceProps = {
withDots?: boolean
balanceTextProps?: TextProps
symbolTextProps?: TextProps
withTooltip?: boolean
} & TextProps

export function CurrencyBalance({
Expand All @@ -44,6 +47,7 @@ export function CurrencyBalance({
as,
balanceTextProps,
symbolTextProps,
withTooltip = false,
...textProps
}: CurrencyBalanceProps) {
const styles = useMultiStyleConfig("CurrencyBalance", {
Expand All @@ -67,7 +71,7 @@ export function CurrencyBalance({
return numberToLocaleString(value, desiredDecimals)
}, [amount, decimals, desiredDecimals, shouldBeFormatted, withRoundUp])

return (
const content = (
<Box as={as} __css={styles.container}>
<Box
as="span"
Expand All @@ -76,11 +80,23 @@ export function CurrencyBalance({
{...balanceTextProps}
>
{balance}
{withDots && ".."}
{withDots && "..."}
</Box>
<Box as="span" __css={styles.symbol} {...textProps} {...symbolTextProps}>
{symbol}
</Box>
</Box>
)

if (withTooltip) {
const tooltipLabel = `${bigIntToUserAmount(BigInt(amount ?? 0), decimals, decimals)} ${symbol}`

return (
<Tooltip label={tooltipLabel} shouldWrapChildren>
{content}
</Tooltip>
)
}

return content
}
17 changes: 15 additions & 2 deletions dapp/src/pages/DashboardPage/AcrePointsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import {
} from "@chakra-ui/react"
import Countdown from "#/components/shared/Countdown"
import { logPromiseFailure, numberToLocaleString } from "#/utils"
import { useAcrePoints } from "#/hooks"
import { useAcrePoints, useWallet } from "#/hooks"
import Spinner from "#/components/shared/Spinner"
import { IconInfoCircle } from "@tabler/icons-react"
import UserDataSkeleton from "#/components/shared/UserDataSkeleton"
import InfoTooltip from "#/components/shared/InfoTooltip"

export default function AcrePointsCard(props: CardProps) {
const {
Expand All @@ -29,6 +30,9 @@ export default function AcrePointsCard(props: CardProps) {
updatePointsData,
isCalculationInProgress,
} = useAcrePoints()
const { address } = useWallet()

const isWalletConnected = !!address

const formattedTotalPointsAmount = numberToLocaleString(totalBalance)
const formattedClaimablePointsAmount = numberToLocaleString(claimableBalance)
Expand All @@ -47,10 +51,19 @@ export default function AcrePointsCard(props: CardProps) {
py={5}
{...props}
>
<CardHeader p={0} mb={2}>
<CardHeader p={0} mb={2} as={HStack} justify="space-between">
<TextMd fontWeight="bold" color="grey.700">
Your Acre points balance
</TextMd>

<InfoTooltip
label={
isWalletConnected
? "Your current balance of Acre points collected so far. New points drop daily and are ready to be claimed. Unclaimed points roll over to the next day."
: "Total points distributed to Acre users so far. New points drop daily and can be claimed in each user's dashboard."
}
w={56}
/>
</CardHeader>

<CardBody p={0}>
Expand Down
11 changes: 8 additions & 3 deletions dapp/src/pages/DashboardPage/BeehiveCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ export default function BeehiveCard(props: CardProps) {

return (
<Card p={4} {...props}>
<CardHeader p={0} as={Flex} alignItems="center" gap={2}>
<CardHeader
p={0}
as={Flex}
alignItems="center"
justify="space-between"
gap={2}
>
<TextMd fontWeight="bold" color="grey.700">
L2 Rewards
</TextMd>
<InfoTooltip
label="Earn rewards from our L2 partners within the Acre Beehive. The rewards are calculated based on amount and time staked. No hassle and automatic participation across each of our launch partners."
color="gold.300"
label="Acre Beehive automatically collects rewards from our partner projects. Rewards are dropped daily, and your share is calculated based on your deposit amount and how long you HODL."
w={56}
/>
</CardHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default function TransactionTable() {
amount={activity.amount}
currency="bitcoin"
withDots
withTooltip
/>
</Flex>
<Flex justifyContent="space-between">
Expand Down
Loading