Loading.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React, { Component } from "react";
  2. import styled from "styled-components";
  3. import loading from "assets/loading.gif";
  4. type PropsType = {
  5. offset?: string;
  6. width?: string;
  7. height?: string;
  8. message?: string;
  9. };
  10. type StateType = {};
  11. export default class Loading extends Component<PropsType, StateType> {
  12. state = {};
  13. render() {
  14. return (
  15. <StyledLoading
  16. offset={this.props.offset}
  17. width={this.props.width || "100%"}
  18. height={this.props.height || "100%"}
  19. >
  20. <Spinner src={loading} />
  21. {this.props.message ? (
  22. <StyledMessage>{this.props.message}</StyledMessage>
  23. ) : null}
  24. </StyledLoading>
  25. );
  26. }
  27. }
  28. const Spinner = styled.img`
  29. width: 20px;
  30. `;
  31. type StyleLoadingProps = PropsType;
  32. const StyledLoading = styled.div`
  33. width: ${(props: StyleLoadingProps) => props.width};
  34. height: ${(props: StyleLoadingProps) => props.height};
  35. display: flex;
  36. align-items: center;
  37. justify-content: center;
  38. flex-direction: column;
  39. margin-top: ${(props: StyleLoadingProps) => props.offset};
  40. `;
  41. const StyledMessage = styled.div`
  42. margin-block: 15px;
  43. color: #aaaabb;
  44. `;