From caff2aa9d2ae2c86a4ce19df6b1fbcf477dc1ba4 Mon Sep 17 00:00:00 2001 From: fmtabbara Date: Wed, 25 Oct 2023 10:02:08 +0100 Subject: [PATCH] format delegations summary --- .../src/components/Rewards/RewardsSummary.tsx | 77 +++++++++++++------ 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/nym-wallet/src/components/Rewards/RewardsSummary.tsx b/nym-wallet/src/components/Rewards/RewardsSummary.tsx index c6e48b395c..75f7da4a7b 100644 --- a/nym-wallet/src/components/Rewards/RewardsSummary.tsx +++ b/nym-wallet/src/components/Rewards/RewardsSummary.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { CircularProgress, Stack, Typography } from '@mui/material'; +import { CircularProgress, Stack, StackProps, Typography, useMediaQuery } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import { useDelegationContext } from 'src/context/delegations'; import { InfoTooltip } from '../InfoToolTip'; @@ -9,34 +9,63 @@ export const RewardsSummary: FCWithChildren<{ totalDelegation?: string; totalRewards?: string; }> = ({ isLoading, totalDelegation, totalRewards }) => { - const theme = useTheme(); - const { totalDelegationsAndRewards } = useDelegationContext(); return ( - - - Total delegations: - - {isLoading ? : totalDelegationsAndRewards || '-'} - - - - - Original delegations: - - {isLoading ? : totalDelegation || '-'} - - - - - Total rewards: - - {isLoading ? : totalRewards || '-'} - - + + } + /> + } + /> + + } + /> ); }; + +const RewardSummaryField = ({ + title, + value, + Tooltip, + isLoading, +}: { + title: string; + value: string; + Tooltip?: React.ReactNode; + isLoading?: boolean; +}) => { + const breakpoint = useMediaQuery(useTheme().breakpoints.down('xl')); + const alignProps: { gap: number; direction: StackProps['direction'] } = { + gap: breakpoint ? 0 : 1, + direction: breakpoint ? 'column' : 'row', + }; + + return ( + + + {Tooltip} + {title}: + + + {isLoading ? : value} + + + ); +};