2020-07-30 10:08:21 +02:00
|
|
|
import React from 'react';
|
2020-07-30 05:09:41 +02:00
|
|
|
import { useSpring, animated } from 'react-spring';
|
2020-08-19 23:35:38 +02:00
|
|
|
import { formatNumber } from '../../lib/format';
|
2020-07-29 04:04:45 +02:00
|
|
|
import styles from './MetricCard.module.css';
|
|
|
|
|
2020-08-19 23:35:38 +02:00
|
|
|
const MetricCard = ({ value = 0, label, format = formatNumber }) => {
|
2020-07-30 05:09:41 +02:00
|
|
|
const props = useSpring({ x: value, from: { x: 0 } });
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.card}>
|
|
|
|
<animated.div className={styles.value}>{props.x.interpolate(x => format(x))}</animated.div>
|
|
|
|
<div className={styles.label}>{label}</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2020-07-29 04:04:45 +02:00
|
|
|
|
|
|
|
export default MetricCard;
|