ConfirmOverlay.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import React, { Component } from "react";
  2. import styled from "styled-components";
  3. type PropsType = {
  4. message: string;
  5. show: boolean;
  6. onYes: React.MouseEventHandler;
  7. onNo: React.MouseEventHandler;
  8. };
  9. type StateType = {};
  10. export default class ConfirmOverlay extends Component<PropsType, StateType> {
  11. render() {
  12. if (this.props.show) {
  13. return (
  14. <StyledConfirmOverlay>
  15. {this.props.message}
  16. <ButtonRow>
  17. <ConfirmButton onClick={this.props.onYes}>Yes</ConfirmButton>
  18. <ConfirmButton onClick={this.props.onNo}>No</ConfirmButton>
  19. </ButtonRow>
  20. </StyledConfirmOverlay>
  21. );
  22. }
  23. return null;
  24. }
  25. }
  26. const StyledConfirmOverlay = styled.div`
  27. position: absolute;
  28. top: 0px;
  29. opacity: 100%;
  30. left: 0px;
  31. width: 100%;
  32. height: 100%;
  33. z-index: 999;
  34. display: flex;
  35. padding-bottom: 30px;
  36. align-items: center;
  37. justify-content: center;
  38. font-family: "Work Sans", sans-serif;
  39. font-size: 18px;
  40. font-weight: 500;
  41. color: white;
  42. flex-direction: column;
  43. background: rgb(0, 0, 0, 0.73);
  44. opacity: 0;
  45. animation: lindEnter 0.2s;
  46. animation-fill-mode: forwards;
  47. @keyframes lindEnter {
  48. from {
  49. opacity: 0;
  50. }
  51. to {
  52. opacity: 1;
  53. }
  54. }
  55. `;
  56. const ButtonRow = styled.div`
  57. display: flex;
  58. align-items: center;
  59. justify-content: space-between;
  60. width: 180px;
  61. margin-top: 30px;
  62. `;
  63. const ConfirmButton = styled.div`
  64. font-size: 18px;
  65. padding: 10px 15px;
  66. outline: none;
  67. border: 1px solid white;
  68. border-radius: 10px;
  69. text-align: center;
  70. width: 80px;
  71. cursor: pointer;
  72. opacity: 0;
  73. font-family: "Work Sans", sans-serif;
  74. font-size: 18px;
  75. font-weight: 500;
  76. animation: linEnter 0.3s 0.1s;
  77. animation-fill-mode: forwards;
  78. @keyframes linEnter {
  79. from {
  80. transform: translateY(20px);
  81. opacity: 0;
  82. }
  83. to {
  84. transform: translateY(0px);
  85. opacity: 1;
  86. }
  87. }
  88. :hover {
  89. background: white;
  90. color: #232323;
  91. }
  92. `;