diff --git a/.changelog/1284.trivial.md b/.changelog/1284.trivial.md new file mode 100644 index 000000000..ce30c36a1 --- /dev/null +++ b/.changelog/1284.trivial.md @@ -0,0 +1 @@ +Consensus Snaphot cards tweaks diff --git a/src/app/components/ProgressBar/index.tsx b/src/app/components/ProgressBar/index.tsx index 39098f3b1..cbc66cb53 100644 --- a/src/app/components/ProgressBar/index.tsx +++ b/src/app/components/ProgressBar/index.tsx @@ -35,3 +35,12 @@ export const ProgressBar = styled(LinearProgress)(() => ({ height: '12px', width: '85px', })) + +export const BrandProgressBar = styled(LinearProgress)(() => ({ + [`&.${linearProgressClasses.determinate} > .${linearProgressClasses.bar1Determinate}`]: { + backgroundColor: COLORS.brandDark, + }, + borderColor: COLORS.grayLight, + backgroundColor: COLORS.grayLight, + height: '12px', +})) diff --git a/src/app/components/Snapshots/SnapshotCard.tsx b/src/app/components/Snapshots/SnapshotCard.tsx index 6c0f04a2e..f117be021 100644 --- a/src/app/components/Snapshots/SnapshotCard.tsx +++ b/src/app/components/Snapshots/SnapshotCard.tsx @@ -61,7 +61,13 @@ export const SnapshotCard: FC = ({ }} > {badge} - + {label} @@ -87,6 +93,10 @@ export const SnapshotTextCard: FC = ({ children, label, t fontSize: '32px', fontWeight: 700, color: COLORS.brandDark, + flex: 1, + textAlign: 'center', + paddingLeft: 4, + paddingRight: 4, }} > {children} diff --git a/src/app/components/Snapshots/SnapshotCardDurationLabel.tsx b/src/app/components/Snapshots/SnapshotCardDurationLabel.tsx index a3321598f..438199565 100644 --- a/src/app/components/Snapshots/SnapshotCardDurationLabel.tsx +++ b/src/app/components/Snapshots/SnapshotCardDurationLabel.tsx @@ -13,7 +13,7 @@ export const SnapshotCardDurationLabel: FC = ({ label, v } return ( - + {label} {value.toLocaleString()} diff --git a/src/app/pages/ConsensusDashboardPage/ConsensusSnapshot.tsx b/src/app/pages/ConsensusDashboardPage/ConsensusSnapshot.tsx index d8faf2e19..bb91738c0 100644 --- a/src/app/pages/ConsensusDashboardPage/ConsensusSnapshot.tsx +++ b/src/app/pages/ConsensusDashboardPage/ConsensusSnapshot.tsx @@ -11,9 +11,9 @@ export const ConsensusSnapshot: FC<{ scope: SearchScope }> = ({ scope }) => { const { t } = useTranslation() return ( - + - + diff --git a/src/app/pages/ConsensusDashboardPage/SnapshotDelegators.tsx b/src/app/pages/ConsensusDashboardPage/SnapshotDelegators.tsx index 82a6deb2d..b833874d6 100644 --- a/src/app/pages/ConsensusDashboardPage/SnapshotDelegators.tsx +++ b/src/app/pages/ConsensusDashboardPage/SnapshotDelegators.tsx @@ -1,13 +1,18 @@ import { FC } from 'react' import { useTranslation } from 'react-i18next' +import Box from '@mui/material/Box' import { SnapshotTextCard } from '../../components/Snapshots/SnapshotCard' +import { useScreenSize } from '../../hooks/useScreensize' export const SnapshotDelegators: FC = () => { const { t } = useTranslation() + const { isMobile } = useScreenSize() + // TODO: provide delegators number when API is ready + const delegators = undefined return ( - {/* TODO: provide delegators number when API is ready */}- + {delegators} ) } diff --git a/src/app/pages/ConsensusDashboardPage/SnapshotEpoch.tsx b/src/app/pages/ConsensusDashboardPage/SnapshotEpoch.tsx index 1ae90fdde..d283fe3e6 100644 --- a/src/app/pages/ConsensusDashboardPage/SnapshotEpoch.tsx +++ b/src/app/pages/ConsensusDashboardPage/SnapshotEpoch.tsx @@ -1,13 +1,66 @@ import { FC } from 'react' -import { useTranslation } from 'react-i18next' +import { Trans, useTranslation } from 'react-i18next' +import Box from '@mui/material/Box' +import Typography from '@mui/material/Typography' +import { styled } from '@mui/material/styles' +import { useGetStatus } from '../../../oasis-nexus/api' +import { SearchScope } from '../../../types/searchScope' +import { COLORS } from '../../../styles/theme/colors' import { SnapshotTextCard } from '../../components/Snapshots/SnapshotCard' +import { BrandProgressBar } from '../../components/ProgressBar' -export const SnapshotEpoch: FC = () => { +const StyledBox = styled(Box)(({ theme }) => ({ + marginTop: `-${theme.spacing(3)}`, + marginBottom: theme.spacing(3), +})) + +export const SnapshotEpoch: FC<{ scope: SearchScope }> = ({ scope }) => { const { t } = useTranslation() + const statusQuery = useGetStatus(scope.network) + const blockHeight = statusQuery?.data?.data.latest_block + // TODO: provide epoch number when API is ready + const epoch = undefined + const percentageValue = undefined return ( - - {/* TODO: provide epoch number when API is ready */}- + + + + {blockHeight.toLocaleString()} + + ), + }} + /> + + + ) + } + > + {epoch && ( + <> + {percentageValue && ( + + + + )} + + {/* TODO: remove casting when real types are available, validate percentageValue formatting */} + {(epoch as number).toLocaleString()} + {percentageValue && ( + ({percentageValue}) + )} + + + )} ) } diff --git a/src/app/pages/ConsensusDashboardPage/SnapshotStaked.tsx b/src/app/pages/ConsensusDashboardPage/SnapshotStaked.tsx index a4d05c65e..676ccb55a 100644 --- a/src/app/pages/ConsensusDashboardPage/SnapshotStaked.tsx +++ b/src/app/pages/ConsensusDashboardPage/SnapshotStaked.tsx @@ -1,13 +1,49 @@ import { FC } from 'react' -import { useTranslation } from 'react-i18next' +import { Trans, useTranslation } from 'react-i18next' +import Box from '@mui/material/Box' +import Typography from '@mui/material/Typography' +import { COLORS } from '../../../styles/theme/colors' +import { RoundedBalance } from '../../components/RoundedBalance' import { SnapshotTextCard } from '../../components/Snapshots/SnapshotCard' export const SnapshotStaked: FC = () => { const { t } = useTranslation() + // TODO: provide label and staked values when API is ready, validate percentageValue formatting + const staked = undefined + const percentageValue = undefined return ( - - {/* TODO: provide label and staked values when API is ready */}- + + + + {t('common.valuePair', { + value: percentageValue, + formatParams: { + value: { + style: 'percent', + maximumFractionDigits: 2, + } satisfies Intl.NumberFormatOptions, + }, + })} + + ), + }} + /> + + + ) + } + > + {staked && } ) } diff --git a/src/app/pages/ConsensusDashboardPage/SnapshotValidators.tsx b/src/app/pages/ConsensusDashboardPage/SnapshotValidators.tsx index 83ef57bd2..6c761225f 100644 --- a/src/app/pages/ConsensusDashboardPage/SnapshotValidators.tsx +++ b/src/app/pages/ConsensusDashboardPage/SnapshotValidators.tsx @@ -39,15 +39,17 @@ export const SnapshotValidators: FC<{ scope: SearchScope }> = ({ scope }) => { return ( - value.toLocaleString(), - label: (status: string) => t('validator.groupStatus', { status }), - }} - /> + {!!validators?.length && ( + value.toLocaleString(), + label: (status: string) => t('validator.groupStatus', { status }), + }} + /> + )} ) } diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 166efb38a..6fb10063a 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -147,7 +147,11 @@ "explainVerificationDelay": "If you have just verified a contract, it should take a few minutes to update here." } }, - "consensusSnapshot": "Consensus Snapshot", + "consensusSnapshot": { + "blockHeight": "Block Height ", + "title": "Consensus Snapshot", + "totalCirculation": "This is of the total circulation" + }, "currentEpoch": "Current Epoch", "dapps": { "wrose": {