2022-06-20 22:26:47 +01:00
|
|
|
import React from 'react';
|
|
|
|
import Icon from '@/components/elements/Icon';
|
|
|
|
import { IconDefinition } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
import Tooltip from '@/components/elements/tooltip/Tooltip';
|
2022-06-21 23:43:59 +01:00
|
|
|
import styles from './style.module.css';
|
2022-06-20 22:26:47 +01:00
|
|
|
|
|
|
|
interface StatBlockProps {
|
|
|
|
title: string;
|
|
|
|
description?: string;
|
|
|
|
color?: string | undefined;
|
|
|
|
icon: IconDefinition;
|
|
|
|
children: React.ReactNode;
|
2022-06-21 23:43:59 +01:00
|
|
|
className?: string;
|
2022-06-20 22:26:47 +01:00
|
|
|
}
|
|
|
|
|
2022-06-21 23:43:59 +01:00
|
|
|
export default ({ title, icon, color, description, className, children }: StatBlockProps) => {
|
2022-06-20 22:26:47 +01:00
|
|
|
return (
|
|
|
|
<Tooltip arrow placement={'top'} disabled={!description} content={description || ''}>
|
2022-06-21 23:43:59 +01:00
|
|
|
<div className={classNames(styles.stat_block, 'bg-gray-600', className)}>
|
|
|
|
<div className={classNames(styles.status_bar, color || 'bg-gray-700')}/>
|
|
|
|
<div className={classNames(styles.icon, color || 'bg-gray-700')}>
|
2022-06-20 22:26:47 +01:00
|
|
|
<Icon
|
|
|
|
icon={icon}
|
2022-06-21 23:43:59 +01:00
|
|
|
className={classNames({
|
|
|
|
'text-gray-100': !color || color === 'bg-gray-700',
|
|
|
|
'text-gray-50': color && color !== 'bg-gray-700',
|
|
|
|
})}
|
2022-06-20 22:26:47 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className={'flex flex-col justify-center overflow-hidden'}>
|
2022-06-21 23:43:59 +01:00
|
|
|
<p className={'font-header leading-tight text-xs md:text-sm text-gray-200'}>{title}</p>
|
|
|
|
<p className={'text-base md:text-xl font-semibold text-gray-50 truncate'}>
|
2022-06-20 22:26:47 +01:00
|
|
|
{children}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Tooltip>
|
|
|
|
);
|
|
|
|
};
|