Show the resource limits next to numbers
This commit is contained in:
parent
5f156e193a
commit
050d4e7a36
3 changed files with 46 additions and 56 deletions
|
@ -2,7 +2,6 @@ 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';
|
||||
import styles from './style.module.css';
|
||||
import useFitText from 'use-fit-text';
|
||||
import CopyOnClick from '@/components/elements/CopyOnClick';
|
||||
|
@ -10,18 +9,17 @@ import CopyOnClick from '@/components/elements/CopyOnClick';
|
|||
interface StatBlockProps {
|
||||
title: string;
|
||||
copyOnClick?: string;
|
||||
description?: string;
|
||||
color?: string | undefined;
|
||||
icon: IconDefinition;
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export default ({ title, copyOnClick, icon, color, description, className, children }: StatBlockProps) => {
|
||||
export default ({ title, copyOnClick, icon, color, className, children }: StatBlockProps) => {
|
||||
const { fontSize, ref } = useFitText({ minFontSize: 8, maxFontSize: 500 });
|
||||
|
||||
return (
|
||||
<Tooltip arrow placement={'top'} disabled={!description} content={description || ''}>
|
||||
<CopyOnClick text={copyOnClick}>
|
||||
<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')}>
|
||||
|
@ -35,17 +33,15 @@ export default ({ title, copyOnClick, icon, color, description, className, child
|
|||
</div>
|
||||
<div className={'flex flex-col justify-center overflow-hidden w-full'}>
|
||||
<p className={'font-header leading-tight text-xs md:text-sm text-gray-200'}>{title}</p>
|
||||
<CopyOnClick text={copyOnClick}>
|
||||
<div
|
||||
ref={ref}
|
||||
className={'h-[1.75rem] w-full font-semibold text-gray-50 truncate'}
|
||||
style={{ fontSize }}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</CopyOnClick>
|
||||
<div
|
||||
ref={ref}
|
||||
className={'h-[1.75rem] w-full font-semibold text-gray-50 truncate'}
|
||||
style={{ fontSize }}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Tooltip>
|
||||
</CopyOnClick>
|
||||
);
|
||||
};
|
||||
|
|
Reference in a new issue