Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | import React from "react";
// mui
import Stack from "@mui/material/Stack";
import { useTheme } from "@mui/material/styles";
import Box, { BoxProps } from "@mui/material/Box";
// components
import { Text } from "@common/Text";
type StatsBarProps = BoxProps & {
keyName: string;
value: number;
width: string;
color?: string;
valueProps?: React.ReactNode;
};
const StatsBar = (props: StatsBarProps) => {
const theme = useTheme();
// let MAX: number;
// let MIN: number;
// if (props.keyName === "Amount") {
// MAX = 100000;
// MIN = 1000;
// } else if (props.keyName === "Visitors") {
// MAX = 300;
// MIN = 1;
// } else if (props.keyName === "Transactions") {
// MAX = 500;
// MIN = 1;
// } else {
// MAX = 2000;
// MIN = 100;
// }
// const normalise = (value: number) => ((value - MIN) * 100) / (MAX - MIN);
return (
<Box
sx={{
height: 24,
width: 502.5,
overflow: "hidden",
position: "relative",
background: "inherit",
borderRadius: "100px",
"&:not(:last-of-type)": {
mb: 0.5,
},
"& sup": {
fontSize: "9px",
lineHeight: "9px",
},
...props.sx,
}}
{...props}
>
<Box
sx={{
top: 0,
left: 0,
bottom: 0,
height: "100%",
width: props.width,
padding: "2px 16px",
position: "absolute",
borderRadius: "100px",
transition: "transform .4s linear",
// width: `${normalise(props.value)}%`,
background: props.color ? props.color : theme.palette.secondary[600],
boxShadow:
"2px 2px 4px rgba(135, 105, 54, 0.25), inset 4px 4px 12px rgba(215, 201, 153, 0.5)",
}}
>
<Stack
direction="row"
alignItems="center"
justifyContent="space-between"
>
<Text color={theme.palette.common.white}>{props.keyName}</Text>
{props.valueProps ? (
<>{props.valueProps}</>
) : (
<Text fontWeight="bold" color={theme.palette.common.white}>
{props.value}
</Text>
)}
</Stack>
</Box>
</Box>
);
};
export default StatsBar;
|