perf: improve monitor detail style, enhance style difference

This commit is contained in:
moonrailgun 2024-09-24 00:11:47 +08:00
parent 22d76a0f87
commit f2ce1fb10c
4 changed files with 23 additions and 5 deletions

View File

@ -89,8 +89,9 @@ export const CommonList: React.FC<CommonListProps> = React.memo((props) => {
<button <button
key={item.id} key={item.id}
className={cn( className={cn(
'hover:bg-accent flex flex-col items-start gap-2 rounded-lg border p-3 text-left text-sm transition-all', 'flex flex-col items-start gap-2 rounded-lg border p-3 text-left text-sm transition-all',
isSelected && 'bg-muted' 'hover:bg-gray-50 dark:hover:bg-gray-900',
isSelected && 'bg-gray-50 dark:bg-gray-900'
)} )}
onClick={() => { onClick={() => {
globalEventBus.emit('commonListSelected'); globalEventBus.emit('commonListSelected');

View File

@ -9,11 +9,13 @@ import { getMonitorProvider, getProviderDisplay } from './provider';
import { MonitorProvider } from './provider/types'; import { MonitorProvider } from './provider/types';
import { useTranslation } from '@i18next-toolkit/react'; import { useTranslation } from '@i18next-toolkit/react';
import clsx from 'clsx'; import clsx from 'clsx';
import { cn } from '@/utils/style';
interface MonitorHealthBarProps { interface MonitorHealthBarProps {
workspaceId: string; workspaceId: string;
monitorId: string; monitorId: string;
monitorType?: string; monitorType?: string;
active?: boolean;
count?: number; count?: number;
size?: HealthBarProps['size']; size?: HealthBarProps['size'];
healthBarClassName?: string; healthBarClassName?: string;
@ -29,6 +31,7 @@ export const MonitorHealthBar: React.FC<MonitorHealthBarProps> = React.memo(
const { const {
workspaceId, workspaceId,
monitorId, monitorId,
active = true,
size = 'small', size = 'small',
count = 20, count = 20,
showCurrentStatus = false, showCurrentStatus = false,
@ -106,7 +109,9 @@ export const MonitorHealthBar: React.FC<MonitorHealthBarProps> = React.memo(
}); });
return ( return (
<div className="flex items-center"> <div
className={cn('flex items-center', active === false && 'opacity-50')}
>
{showPercent && ( {showPercent && (
<span <span
className={clsx( className={clsx(
@ -131,7 +136,18 @@ export const MonitorHealthBar: React.FC<MonitorHealthBarProps> = React.memo(
{showCurrentStatus && ( {showCurrentStatus && (
<> <>
{last(beats)?.status === 'health' ? ( {active === false ? (
<div
className={clsx(
'ml-2 rounded-full bg-gray-400 px-4 py-1 text-lg font-bold text-white',
{
'text-sm': size === 'small',
}
)}
>
{t('Stopped')}
</div>
) : last(beats)?.status === 'health' ? (
<div <div
className={clsx( className={clsx(
'ml-2 rounded-full bg-green-500 px-4 py-1 text-lg font-bold text-white', 'ml-2 rounded-full bg-green-500 px-4 py-1 text-lg font-bold text-white',

View File

@ -261,7 +261,7 @@ export const MonitorInfo: React.FC<MonitorInfoProps> = React.memo((props) => {
)} )}
</Space> </Space>
<div className="text-black text-opacity-75 dark:text-gray-200"> <div className="text-right text-black text-opacity-75 dark:text-gray-200">
<div> <div>
{t('Monitored for {{dayNum}} days', { {t('Monitored for {{dayNum}} days', {
dayNum: dayjs().diff(dayjs(monitorInfo.createdAt), 'days'), dayNum: dayjs().diff(dayjs(monitorInfo.createdAt), 'days'),

View File

@ -43,6 +43,7 @@ function MonitorComponent() {
<MonitorHealthBar <MonitorHealthBar
workspaceId={workspaceId} workspaceId={workspaceId}
monitorId={item.id} monitorId={item.id}
active={item.active}
showPercent={true} showPercent={true}
showCurrentStatus={true} showCurrentStatus={true}
/> />