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

Merits dashboard minor changes #2637

Open
wants to merge 1 commit into
base: main
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
43 changes: 20 additions & 23 deletions ui/pages/RewardsDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,19 @@ const RewardsDashboard = () => {
description="Claim your daily Merits and any Merits received from referrals."
direction="column-reverse"
contentAfter={ <DailyRewardClaimButton/> }
hint={ (
<>
Total number of Merits earned from all activities.{ ' ' }
<LinkExternal href="https://docs.blockscout.com/using-blockscout/merits">
More info on Merits
</LinkExternal>
</>
) }
>
<RewardsDashboardCardValue
label="Total balance"
value={ balancesQuery.data?.total || 'N/A' }
isLoading={ balancesQuery.isPending }
withIcon
hint={ (
<>
Total number of Merits earned from all activities.{ ' ' }
<LinkExternal href="https://docs.blockscout.com/using-blockscout/merits">
More info on Merits
</LinkExternal>
</>
) }
/>
</RewardsDashboardCard>
<RewardsDashboardCard
Expand All @@ -89,7 +88,6 @@ const RewardsDashboard = () => {
direction="column-reverse"
>
<RewardsDashboardCardValue
label="Referrals"
value={ referralsQuery.data?.referrals ?
`${ referralsQuery.data?.referrals } user${ Number(referralsQuery.data?.referrals) === 1 ? '' : 's' }` :
'N/A'
Expand All @@ -111,28 +109,27 @@ const RewardsDashboard = () => {
</LinkExternal>
</>
) }
hint={ (
<>
See the{ ' ' }
<LinkExternal
href="https://docs.blockscout.com/using-blockscout/merits/streak-rewards"
isExternal
>
docs
</LinkExternal>{ ' ' }
to learn how your streak number affects daily rewards
</>
) }
direction="column-reverse"
>
<RewardsDashboardCardValue
label="Streak"
value={
dailyRewardQuery.data?.streak ?
`${ dailyRewardQuery.data?.streak } day${ Number(dailyRewardQuery.data?.streak) === 1 ? '' : 's' }` :
'N/A'
}
isLoading={ dailyRewardQuery.isPending }
hint={ (
<>
See the{ ' ' }
<LinkExternal
href="https://docs.blockscout.com/using-blockscout/merits/streak-rewards"
isExternal
>
docs
</LinkExternal>{ ' ' }
to learn how your streak number affects daily rewards
</>
) }
/>
</RewardsDashboardCard>
</Flex>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 18 additions & 8 deletions ui/rewards/dashboard/RewardsDashboardCard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Flex, Text, useColorModeValue, Tag } from '@chakra-ui/react';
import React from 'react';

import HintPopover from 'ui/shared/HintPopover';

type Props = {
title?: string;
title: string;
description: string | React.ReactNode;
hint?: string | React.ReactNode;
availableSoon?: boolean;
blurFilter?: boolean;
contentAfter?: React.ReactNode;
Expand All @@ -13,7 +16,7 @@ type Props = {
};

const RewardsDashboardCard = ({
title, description, availableSoon, contentAfter,
title, description, hint, availableSoon, contentAfter,
direction = 'column', children, blurFilter,
}: Props) => {
return (
Expand All @@ -34,12 +37,19 @@ const RewardsDashboardCard = ({
p={{ base: 1.5, md: 3 }}
w={{ base: 'full', md: direction === 'row' ? '340px' : 'full' }}
>
{ title && (
<Flex alignItems="center" gap={ 2 }>
<Text fontSize={{ base: 'md', md: 'lg' }} fontWeight="500">{ title }</Text>
{ availableSoon && <Tag colorScheme="blue">Available soon</Tag> }
</Flex>
) }
<Flex alignItems="center" gap={ 2 }>
<Text fontSize={{ base: 'md', md: 'lg' }} fontWeight="500">{ title }</Text>
{ hint && (
<HintPopover
label={ hint }
popoverContentProps={{
maxW: { base: 'calc(100vw - 8px)', lg: '210px' },
}}
popoverBodyProps={{ textAlign: 'center' }}
/>
) }
{ availableSoon && <Tag colorScheme="blue">Available soon</Tag> }
</Flex>
<Text as="div" fontSize="sm">
{ description }
</Text>
Expand Down
28 changes: 15 additions & 13 deletions ui/rewards/dashboard/RewardsDashboardCardValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import HintPopover from 'ui/shared/HintPopover';
import MeritsIcon from '../MeritsIcon';

type Props = {
label: string;
label?: string;
value: number | string | undefined;
withIcon?: boolean;
hint?: string | React.ReactNode;
Expand All @@ -16,18 +16,20 @@ type Props = {

const RewardsDashboardCard = ({ label, value, withIcon, hint, isLoading }: Props) => (
<Flex key={ label } flexDirection="column" alignItems="center" gap={ 2 }>
<Flex alignItems="center" gap={ 1 }>
{ hint && (
<HintPopover
label={ hint }
popoverContentProps={{ maxW: { base: 'calc(100vw - 8px)', lg: '210px' } }}
popoverBodyProps={{ textAlign: 'center' }}
/>
) }
<Text fontSize="xs" fontWeight="500" variant="secondary">
{ label }
</Text>
</Flex>
{ label && (
<Flex alignItems="center" gap={ 1 }>
{ hint && (
<HintPopover
label={ hint }
popoverContentProps={{ maxW: { base: 'calc(100vw - 8px)', lg: '210px' } }}
popoverBodyProps={{ textAlign: 'center' }}
/>
) }
<Text fontSize="xs" fontWeight="500" variant="secondary">
{ label }
</Text>
</Flex>
) }
<Skeleton
isLoaded={ !isLoading }
display="flex"
Expand Down
Loading