Files
js/components/analytics/stack-tooltip.tsx
T
Adam Majmudar acac8e2200 Add analytics 🚀 (#1203)
* Add analytics

* Remove analytics secret

* Add date range picker and timestamp

* Refactor and add logs

* Update

* Remove cumulative wallets stat

* Add beta tag to analytics

* Add function calls table

* Add key

* Fix prettier

* Add event breakdown

* Add banner and total statistics

* Remove total txs

* Update analytics

* Fix suspense bug

* Add suspense to analytics stats

* Fix suspense

* Fix update

* Add zero states for charts

* Remove unused import

* Fix date ranges, add stack, add commas

* Cap end date

* Disable date selection

* Switch to new GET API format

* Update

* Fix stacked bar chart

* Add commas to values

* Fix highlight for stack

* Update colors to blue first

* Update color scheme

* Update bar colors
2023-06-03 00:00:24 +00:00

63 lines
1.4 KiB
TypeScript

import { Flex, useColorMode } from "@chakra-ui/react";
import { Heading, Text } from "tw-components";
type CustomToolTipProps = {
time: string;
values: Record<string, number>;
};
const formattingOptions: Intl.DateTimeFormatOptions = {
year: "numeric",
month: "short",
day: "numeric",
};
export const StackToolTip: React.FC<CustomToolTipProps> = ({
time,
values,
}) => {
const { colorMode } = useColorMode();
return (
<Flex
py={1.5}
px={2.5}
backdropFilter="blur(10px)"
bg="transparent"
flexDirection="column"
gap={1}
border="none"
outline="none"
borderRadius="lg"
_dark={{
bg: "rgba(0,0,0,0.2)",
}}
_light={{
bg: "rgba(255,255,255,0.2)",
}}
>
<Flex direction="column" gap={0.5}>
<Heading as="label" size="label.sm">
Date
</Heading>
<Text size="body.sm">
{new Date(time).toLocaleDateString(undefined, formattingOptions)}
</Text>
</Flex>
<Flex direction="column" gap={0.5}>
{Object.entries(values).map(([key, value]) => (
<Text
key={key}
fontSize="12px"
color={colorMode === "dark" ? "white" : "#333"}
>
<strong>{key}: </strong>
{value.toLocaleString()}
</Text>
))}
</Flex>
</Flex>
);
};