StatusSection.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import React, { Component } from "react";
  2. import styled from "styled-components";
  3. import loading from "assets/loading.gif";
  4. type PropsType = {
  5. status: string;
  6. };
  7. type StateType = {};
  8. // TODO: replace StatusIndicator
  9. export default class StatusSection extends Component<PropsType, StateType> {
  10. renderIndicator = (status: string) => {
  11. if (status == "loading") {
  12. return (
  13. <div>
  14. <Spinner src={loading} />
  15. </div>
  16. );
  17. }
  18. return (
  19. <div>
  20. <StatusColor status={status} />
  21. </div>
  22. );
  23. };
  24. render() {
  25. return (
  26. <Status>
  27. {this.renderIndicator(this.props.status)}
  28. {this.props.status}
  29. </Status>
  30. );
  31. }
  32. }
  33. const Spinner = styled.img`
  34. width: 15px;
  35. height: 15px;
  36. margin-right: 15px;
  37. margin-bottom: -3px;
  38. `;
  39. const StatusColor = styled.div`
  40. margin-top: 1px;
  41. max-width: 8px;
  42. max-height: 8px;
  43. min-width: 8px;
  44. min-height: 8px;
  45. width: 8px;
  46. height: 8px;
  47. background: ${(props: { status: string }) =>
  48. props.status === "deployed" || props.status === "healthy"
  49. ? "#4797ff"
  50. : props.status === "failed"
  51. ? "#ed5f85"
  52. : props.status === "completed"
  53. ? "#00d12a"
  54. : "#f5cb42"};
  55. border-radius: 4px;
  56. margin-left: 3px;
  57. margin-right: 16px;
  58. `;
  59. const Status = styled.div`
  60. display: flex;
  61. height: 20px;
  62. font-size: 13px;
  63. flex-direction: row;
  64. text-transform: capitalize;
  65. align-items: center;
  66. font-family: "Work Sans", sans-serif;
  67. color: #aaaabb;
  68. animation: fadeIn 0.5s;
  69. @keyframes fadeIn {
  70. from {
  71. opacity: 0;
  72. }
  73. to {
  74. opacity: 1;
  75. }
  76. }
  77. `;