Indicator.tsx 987 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React, { PropsWithChildren } from 'react';
  2. import { AlertType } from 'redux/interfaces';
  3. import * as S from './Metrics.styled';
  4. export interface Props {
  5. fetching?: boolean;
  6. isAlert?: boolean;
  7. label: React.ReactNode;
  8. title?: string;
  9. alertType?: AlertType;
  10. }
  11. const Indicator: React.FC<PropsWithChildren<Props>> = ({
  12. label,
  13. title,
  14. fetching,
  15. isAlert,
  16. alertType = 'error',
  17. children,
  18. }) => (
  19. <S.IndicatorWrapper>
  20. <div title={title}>
  21. <S.IndicatorTitle>
  22. {label}{' '}
  23. {isAlert && (
  24. <S.CircularAlertWrapper>
  25. <S.CircularAlert $type={alertType} />
  26. </S.CircularAlertWrapper>
  27. )}
  28. </S.IndicatorTitle>
  29. <span>
  30. {fetching ? (
  31. <i
  32. className="fas fa-spinner fa-pulse"
  33. role="progressbar"
  34. aria-label="Loading"
  35. />
  36. ) : (
  37. children
  38. )}
  39. </span>
  40. </div>
  41. </S.IndicatorWrapper>
  42. );
  43. export default Indicator;