您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

LoadingMeter.tsx 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React from 'react';
  2. import { Flex, Typography, Divider, Layout, Button, Row, Col, Image } from 'antd';
  3. const { Title, Text } = Typography;
  4. type LoadingMeterProps = {
  5. title: string,
  6. progress: number,
  7. total: number
  8. }
  9. const LoadingMeter: React.FC<LoadingMeterProps> = ({ title = "Title", progress = 0, total = 0 }) => {
  10. const barProgress = (progress * 100) / total;
  11. if (progress > total) return <Text className='!text-red-500'>Progress is more than total</Text>
  12. return (
  13. <Flex vertical gap={2} className="!w-full !max-w-md !mb-2">
  14. {/* Header Row */}
  15. <Row className="flex flex-row justify-between text-sm font-medium text-gray-700">
  16. <Col span={24}>
  17. <Text className='!text-xs'>{`${title}: `}</Text>
  18. <Text className='!text-xs'>{`${progress}/${total}`}</Text>
  19. </Col>
  20. </Row>
  21. {/* Progress Bar */}
  22. <div className="w-full h-3 bg-gray-200 rounded-full border overflow-hidden">
  23. <div
  24. className="h-full bg-[#602FD0] rounded-full transition-all duration-500"
  25. style={{ width: `${barProgress}%` }}
  26. ></div>
  27. </div>
  28. </Flex>
  29. );
  30. };
  31. export default LoadingMeter;