Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

feat(stats): add statistics tooltip icon #149

Merged
merged 1 commit into from
Mar 2, 2021
Merged
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
39 changes: 28 additions & 11 deletions src/components/statistic-raw.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import Box from "@material-ui/core/Box";
import IconButton from "@material-ui/core/IconButton";
import makeStyles from "@material-ui/core/styles/makeStyles";
import Tooltip from "@material-ui/core/Tooltip";
import Typography from "@material-ui/core/Typography";
import InfoOutlinedIcon from "@material-ui/icons/InfoOutlined";
import React, { FC, ReactNode } from "react";

import { RawStatisticConfig } from "../types/statistic-types";
import { STATISTICS_TEXT_COLOR } from "../utils/colors";
import { spaceNumberForAnyValue } from "../utils/number-util";

type StatisticRawProps = {
Expand All @@ -13,15 +15,13 @@ type StatisticRawProps = {

const useDataStyle = makeStyles({
root: {
color: STATISTICS_TEXT_COLOR,
fontSize: "35px",
lineHeight: "47px",
},
});

const useLabelStyle = makeStyles({
root: {
color: STATISTICS_TEXT_COLOR,
fontSize: "15px",
lineHeight: "22px",
marginTop: "8px",
Expand All @@ -32,13 +32,30 @@ const spaceNumber = spaceNumberForAnyValue<ReactNode>({
minDigits: 5,
});

const StatisticRaw: FC<StatisticRawProps> = ({ statistic }) => (
<Box width={1}>
<Typography classes={useDataStyle()}>
{spaceNumber(statistic.value)}
</Typography>
<Typography classes={useLabelStyle()}>{statistic.label}</Typography>
</Box>
);
const StatisticRaw: FC<StatisticRawProps> = ({ statistic }) => {
return (
<Box width={1}>
<Typography classes={useDataStyle()} color="textSecondary">
{spaceNumber(statistic.value)}
</Typography>
<Box display="flex" flexWrap="wrap">
<Typography classes={useLabelStyle()} color="textSecondary">
{statistic.label}{" "}
{statistic.tooltip && (
<Tooltip title={statistic.tooltip}>
<IconButton size="small" aria-label="info">
<InfoOutlinedIcon
fontSize="small"
color="secondary"
titleAccess="info"
/>
</IconButton>
</Tooltip>
)}
</Typography>
</Box>
</Box>
);
};

export default StatisticRaw;
8 changes: 5 additions & 3 deletions src/components/statistics-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Typography from "@material-ui/core/Typography";
import React, { FC } from "react";

import { StatisticsBlock as StatisticsBlockType } from "../types/statistic-types";
import { STATISTICS_TEXT_COLOR } from "../utils/colors";
import Statistic from "./statistic";

type StatisticsBlockProps = {
Expand All @@ -30,7 +29,6 @@ const useCardContentStyles = makeStyles({

const useTitleStyle = makeStyles({
root: {
color: STATISTICS_TEXT_COLOR,
fontSize: "15px",
fontWeight: "bold",
lineHeight: "22px",
Expand All @@ -41,7 +39,11 @@ const useTitleStyle = makeStyles({
const StatisticsBlock: FC<StatisticsBlockProps> = ({ block }) => (
<Card classes={useCardStyles()}>
<CardContent classes={useCardContentStyles()}>
<Typography classes={useTitleStyle()} align="center">
<Typography
classes={useTitleStyle()}
color="textSecondary"
align="center"
>
{block.title}
</Typography>
<Box display="flex" justifyContent="space-around">
Expand Down