Commit 75a9889a authored by tom goriunov's avatar tom goriunov Committed by GitHub

Charts&Stats: add tooltips to number charts (#1192)

Fixes #1151
parent c389dc76
...@@ -58,5 +58,6 @@ export const STATS_COUNTER: Counter = { ...@@ -58,5 +58,6 @@ export const STATS_COUNTER: Counter = {
id: 'stub', id: 'stub',
value: '9074405', value: '9074405',
title: 'Placeholder Counter', title: 'Placeholder Counter',
description: 'Placeholder description',
units: '', units: '',
}; };
...@@ -27,6 +27,7 @@ export type Counter = { ...@@ -27,6 +27,7 @@ export type Counter = {
id: string; id: string;
value: string; value: string;
title: string; title: string;
description?: string;
units: string; units: string;
} }
......
import { Box, Skeleton, useColorModeValue } from '@chakra-ui/react'; import { Box, Flex, Skeleton, useColorModeValue } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import Hint from 'ui/shared/Hint';
type Props = { type Props = {
label: string; label: string;
description?: string;
value: string; value: string;
isLoading?: boolean; isLoading?: boolean;
} }
const NumberWidget = ({ label, value, isLoading }: Props) => { const NumberWidget = ({ label, value, isLoading, description }: Props) => {
const bgColor = useColorModeValue('blue.50', 'blue.800'); const bgColor = useColorModeValue('blue.50', 'blue.800');
const skeletonBgColor = useColorModeValue('blackAlpha.50', 'whiteAlpha.50'); const skeletonBgColor = useColorModeValue('blackAlpha.50', 'whiteAlpha.50');
const hintColor = useColorModeValue('gray.600', 'gray.400');
return ( return (
<Box <Flex
alignItems="flex-start"
bg={ isLoading ? skeletonBgColor : bgColor } bg={ isLoading ? skeletonBgColor : bgColor }
px={ 3 } px={ 3 }
py={{ base: 2, lg: 3 }} py={{ base: 2, lg: 3 }}
borderRadius={ 12 } borderRadius={ 12 }
justifyContent="space-between"
columnGap={ 3 }
>
<Box
> >
<Skeleton <Skeleton
isLoaded={ !isLoading } isLoaded={ !isLoading }
...@@ -35,7 +44,16 @@ const NumberWidget = ({ label, value, isLoading }: Props) => { ...@@ -35,7 +44,16 @@ const NumberWidget = ({ label, value, isLoading }: Props) => {
> >
{ value } { value }
</Skeleton> </Skeleton>
</Box> </Box>
<Skeleton isLoaded={ !isLoading } alignSelf="center" borderRadius="base">
<Hint
label={ description }
boxSize={ 6 }
color={ hintColor }
/>
</Skeleton>
</Flex>
); );
}; };
......
...@@ -24,7 +24,7 @@ const NumberWidgetsList = () => { ...@@ -24,7 +24,7 @@ const NumberWidgetsList = () => {
gridGap={ 4 } gridGap={ 4 }
> >
{ {
data?.counters?.map(({ id, title, value, units }, index) => { data?.counters?.map(({ id, title, value, units, description }, index) => {
return ( return (
<NumberWidget <NumberWidget
...@@ -32,6 +32,7 @@ const NumberWidgetsList = () => { ...@@ -32,6 +32,7 @@ const NumberWidgetsList = () => {
label={ title } label={ title }
value={ `${ Number(value).toLocaleString(undefined, { maximumFractionDigits: 3, notation: 'compact' }) } ${ units ? units : '' }` } value={ `${ Number(value).toLocaleString(undefined, { maximumFractionDigits: 3, notation: 'compact' }) } ${ units ? units : '' }` }
isLoading={ isPlaceholderData } isLoading={ isPlaceholderData }
description={ description }
/> />
); );
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment