Loading.tsx 922 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. };
  9. type StateType = {};
  10. export default class Loading extends Component<PropsType, StateType> {
  11. state = {};
  12. render() {
  13. return (
  14. <StyledLoading
  15. offset={this.props.offset}
  16. width={this.props.width || "100%"}
  17. height={this.props.height || "100%"}
  18. >
  19. <Spinner src={loading} />
  20. </StyledLoading>
  21. );
  22. }
  23. }
  24. const Spinner = styled.img`
  25. width: 20px;
  26. `;
  27. type StyleLoadingProps = PropsType;
  28. const StyledLoading = styled.div`
  29. width: ${(props: StyleLoadingProps) => props.width};
  30. height: ${(props: StyleLoadingProps) => props.height};
  31. display: flex;
  32. align-items: center;
  33. justify-content: center;
  34. margin-top: ${(props: StyleLoadingProps) => props.offset};
  35. `;