2022-06-23 06:32:18 +00:00
|
|
|
import { ReactNode } from 'react';
|
2022-07-06 08:23:53 +00:00
|
|
|
import clsx from 'clsx';
|
2022-06-23 06:32:18 +00:00
|
|
|
|
|
|
|
import { Icon, IconProps } from '@/react/components/Icon';
|
2022-07-06 08:23:53 +00:00
|
|
|
import { pluralize } from '@/portainer/helpers/strings';
|
2022-02-24 23:22:56 +00:00
|
|
|
|
2022-06-23 06:32:18 +00:00
|
|
|
interface Props extends IconProps {
|
|
|
|
value?: number;
|
2022-02-24 23:22:56 +00:00
|
|
|
type: string;
|
2022-06-23 06:32:18 +00:00
|
|
|
children?: ReactNode;
|
2022-02-24 23:22:56 +00:00
|
|
|
}
|
|
|
|
|
2022-06-23 06:32:18 +00:00
|
|
|
export function DashboardItem({
|
|
|
|
value,
|
|
|
|
icon,
|
|
|
|
type,
|
|
|
|
children,
|
|
|
|
featherIcon,
|
|
|
|
}: Props) {
|
2022-02-24 23:22:56 +00:00
|
|
|
return (
|
2022-07-06 08:23:53 +00:00
|
|
|
<div
|
|
|
|
className={clsx(
|
2022-08-01 01:29:49 +00:00
|
|
|
'border-solid rounded-lg border p-3',
|
|
|
|
'bg-gray-2 hover:bg-blue-2 border-gray-5 hover:border-blue-7',
|
|
|
|
'th-dark:bg-gray-iron-10 th-dark:hover:bg-gray-10 th-dark:border-gray-neutral-8 th-dark:hover:border-blue-8',
|
|
|
|
'th-highcontrast:bg-black th-highcontrast:hover:bg-gray-11 th-highcontrast:border-white th-highcontrast:hover:border-blue-8'
|
2022-07-06 08:23:53 +00:00
|
|
|
)}
|
|
|
|
>
|
|
|
|
<div className="flex items-center" aria-label={type}>
|
2022-08-01 01:29:49 +00:00
|
|
|
<div
|
|
|
|
className={clsx(
|
|
|
|
'icon-badge text-2xl mr-4 !p-2',
|
|
|
|
'bg-blue-3 text-blue-8',
|
|
|
|
'th-dark:bg-blue-3 th-dark:text-blue-8',
|
|
|
|
'th-highcontrast:bg-blue-3 th-highcontrast:text-blue-8'
|
|
|
|
)}
|
|
|
|
>
|
2022-07-06 08:23:53 +00:00
|
|
|
<Icon icon={icon} feather={featherIcon} className="feather" />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="flex flex-col justify-around">
|
2022-08-01 01:29:49 +00:00
|
|
|
<div
|
|
|
|
className={clsx(
|
|
|
|
'font-medium text-2xl',
|
|
|
|
'text-gray-9',
|
|
|
|
'th-dark:text-white',
|
|
|
|
'th-highcontrast:text-white'
|
|
|
|
)}
|
|
|
|
aria-label="value"
|
|
|
|
>
|
2022-07-06 08:23:53 +00:00
|
|
|
{typeof value !== 'undefined' ? value : '-'}
|
2022-02-24 23:22:56 +00:00
|
|
|
</div>
|
2022-08-01 01:29:49 +00:00
|
|
|
<div
|
|
|
|
className={clsx(
|
|
|
|
'text-xl',
|
|
|
|
'text-gray-7',
|
|
|
|
'th-dark:text-gray-warm-5',
|
|
|
|
'th-highcontrast:text-gray-warm-5'
|
|
|
|
)}
|
|
|
|
aria-label="resourceType"
|
|
|
|
>
|
2022-07-06 08:23:53 +00:00
|
|
|
{pluralize(value || 0, type)}
|
2022-02-24 23:22:56 +00:00
|
|
|
</div>
|
2022-07-06 08:23:53 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="ml-auto">{children}</div>
|
|
|
|
</div>
|
2022-02-24 23:22:56 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|