loadingIndicator.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {withProfiler} from '@sentry/react';
  2. import classNames from 'classnames';
  3. type Props = {
  4. children?: React.ReactNode;
  5. className?: string;
  6. dark?: boolean;
  7. hideMessage?: boolean;
  8. hideSpinner?: boolean;
  9. mini?: boolean;
  10. overlay?: boolean;
  11. relative?: boolean;
  12. size?: number;
  13. style?: React.CSSProperties;
  14. };
  15. function LoadingIndicator(props: Props) {
  16. const {
  17. hideMessage,
  18. mini,
  19. overlay,
  20. dark,
  21. children,
  22. className,
  23. style,
  24. relative,
  25. size,
  26. hideSpinner,
  27. } = props;
  28. const cx = classNames(className, {
  29. overlay,
  30. dark,
  31. loading: true,
  32. mini,
  33. });
  34. const loadingCx = classNames({
  35. relative,
  36. 'loading-indicator': true,
  37. });
  38. let loadingStyle = {};
  39. if (size) {
  40. loadingStyle = {
  41. width: size,
  42. height: size,
  43. };
  44. }
  45. return (
  46. <div className={cx} style={style} data-test-id="loading-indicator">
  47. {!hideSpinner && <div className={loadingCx} style={loadingStyle} />}
  48. {!hideMessage && <div className="loading-message">{children}</div>}
  49. </div>
  50. );
  51. }
  52. export default withProfiler(LoadingIndicator, {
  53. includeUpdates: false,
  54. });