fix: fix health bar style problem in page

This commit is contained in:
moonrailgun 2024-09-02 22:34:02 +08:00
parent 921dd53a50
commit 01d774d395
3 changed files with 28 additions and 16 deletions

View File

@ -1,4 +1,5 @@
import { useResizeObserver } from '@/hooks/useResizeObserver'; import { useResizeObserver } from '@/hooks/useResizeObserver';
import { cn } from '@/utils/style';
import clsx from 'clsx'; import clsx from 'clsx';
import React from 'react'; import React from 'react';
@ -10,6 +11,7 @@ export interface HealthBarBeat {
} }
export interface HealthBarProps { export interface HealthBarProps {
className?: string;
size?: 'small' | 'large'; size?: 'small' | 'large';
beats: HealthBarBeat[]; beats: HealthBarBeat[];
} }
@ -23,10 +25,14 @@ export const HealthBar: React.FC<HealthBarProps> = React.memo((props) => {
return ( return (
<div <div
ref={containerRef} ref={containerRef}
className={clsx('flex', { className={cn(
'gap-[3px]': size === 'small', 'flex',
'gap-1': size === 'large', {
})} 'gap-[3px] px-0.5 py-1.5': size === 'small',
'gap-1 px-0.5 py-2': size === 'large',
},
props.className
)}
> >
{props.beats {props.beats
.slice( .slice(

View File

@ -16,6 +16,7 @@ interface MonitorHealthBarProps {
monitorType?: string; monitorType?: string;
count?: number; count?: number;
size?: HealthBarProps['size']; size?: HealthBarProps['size'];
healthBarClassName?: string;
showCurrentStatus?: boolean; showCurrentStatus?: boolean;
showPercent?: boolean; showPercent?: boolean;
onBeatsItemUpdate?: ( onBeatsItemUpdate?: (
@ -121,7 +122,11 @@ export const MonitorHealthBar: React.FC<MonitorHealthBarProps> = React.memo(
)} )}
<div className="flex-1 overflow-hidden"> <div className="flex-1 overflow-hidden">
<HealthBar size={size} beats={beats} /> <HealthBar
className={props.healthBarClassName}
size={size}
beats={beats}
/>
</div> </div>
{showCurrentStatus && ( {showCurrentStatus && (

View File

@ -70,7 +70,7 @@ export const MonitorListItem: React.FC<{
<div <div
className={clsx( className={clsx(
className, className,
'mb-1 flex items-center rounded-lg bg-green-500 bg-opacity-0 px-4 py-3 hover:bg-opacity-10', 'mb-1 flex items-center overflow-hidden rounded-lg bg-green-500 bg-opacity-0 px-4 py-3 hover:bg-opacity-10',
onClick && 'cursor-pointer' onClick && 'cursor-pointer'
)} )}
onClick={onClick} onClick={onClick}
@ -86,7 +86,7 @@ export const MonitorListItem: React.FC<{
</span> </span>
</div> </div>
<div className="flex-1 pl-2"> <div className="pl-2">
<div className="text-base">{monitorName}</div> <div className="text-base">{monitorName}</div>
{/* <div> {/* <div>
{monitor.tags.map((tag) => ( {monitor.tags.map((tag) => (
@ -100,6 +100,16 @@ export const MonitorListItem: React.FC<{
</div> */} </div> */}
</div> </div>
<div className="flex-1 flex-shrink items-center overflow-hidden px-1">
<MonitorHealthBar
healthBarClassName="justify-end"
workspaceId={workspaceId}
monitorId={monitorId}
monitorType={monitorType}
onBeatsItemUpdate={setBeats}
/>
</div>
{showCurrentResponse && latestResponse && ( {showCurrentResponse && latestResponse && (
<Tooltip title={t('Current')}> <Tooltip title={t('Current')}>
<div className="px-2 text-sm text-gray-800 dark:text-gray-400"> <div className="px-2 text-sm text-gray-800 dark:text-gray-400">
@ -107,15 +117,6 @@ export const MonitorListItem: React.FC<{
</div> </div>
</Tooltip> </Tooltip>
)} )}
<div className="flex items-center">
<MonitorHealthBar
workspaceId={workspaceId}
monitorId={monitorId}
monitorType={monitorType}
onBeatsItemUpdate={setBeats}
/>
</div>
</div> </div>
); );
}); });