loadingIndicator.tsx 1.2 KB

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