tianji/src/client/components/HealthBar.tsx

31 lines
853 B
TypeScript
Raw Normal View History

2023-09-01 16:52:43 +00:00
import clsx from 'clsx';
import React from 'react';
type HealthStatus = 'health' | 'error' | 'warning' | 'none';
interface HealthBarProps {
beats: { title?: string; status: HealthStatus }[];
}
export const HealthBar: React.FC<HealthBarProps> = React.memo((props) => {
return (
<div className="flex">
2023-09-03 11:28:53 +00:00
{props.beats.map((beat, i) => (
2023-09-01 16:52:43 +00:00
<div
2023-09-03 11:28:53 +00:00
key={i}
2023-09-01 16:52:43 +00:00
title={beat.title}
className={clsx(
'rounded-full w-1 h-4 m-0.5 hover:scale-150 transition-transform',
{
'bg-green-500': beat.status === 'health',
'bg-red-600': beat.status === 'error',
'bg-yellow-400': beat.status === 'warning',
'bg-gray-400': beat.status === 'none',
}
)}
/>
))}
</div>
);
});
HealthBar.displayName = 'HealthBar';