Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

953 B
Raw Blame
import type { ProgressProps } from '@lobehub/ui';
import { cssVar, Flexbox, Progress, Text, Tooltip } from '@lobehub/ui';
import { memo } from 'react';

interface ProgressIconProps extends Omit<ProgressProps, 'percent'> {
  percent?: number | null;
}

const ProgressIcon = memo<ProgressIconProps>(({ showInfo, format, percent, ...rest }) => {
  if (typeof percent !== 'number') return;

  const content = (
    <Progress
      format={format}
      percent={percent}
      segments={5}
      showInfo={false}
      size={12}
      style={{ flex: 'none', width: 18 }}
      variant="segments"
      {...rest}
    />
  );

  if (showInfo)
    return (
      <Flexbox horizontal align={'center'} gap={8}>
        {content}
        <Text color={cssVar.colorTextSecondary} fontSize={12}>
          {format?.(percent)}
        </Text>
      </Flexbox>
    );

  return <Tooltip title={format?.(percent)}>{content}</Tooltip>;
});

export default ProgressIcon;