Advertisement
Fahim_7861

cker

Apr 11th, 2021
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1.  
  2.  
  3. import React from 'react';
  4. import { makeStyles } from '@material-ui/core/styles';
  5. import Modal from '@material-ui/core/Modal';
  6. import wrongSign from "../../assets/images/wrongSign.png";
  7. function rand() {
  8. return Math.round(Math.random() * 20) - 10;
  9. }
  10.  
  11. function getModalStyle() {
  12. const top = 50 + rand();
  13. const left = 50 + rand();
  14.  
  15. return {
  16. top: `${top}%`,
  17. left: `${left}%`,
  18. transform: `translate(-${top}%, -${left}%)`,
  19. };
  20. }
  21.  
  22. const useStyles = makeStyles((theme) => ({
  23.  
  24. paper: {
  25. position: 'absolute',
  26.  
  27.  
  28.  
  29. },
  30. }));
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. const JoinModal = ({modalState, modalIsOpen,closeModal,JoinExam}) => {
  38.  
  39.  
  40. const classes = useStyles();
  41. // getModalStyle is not a pure function, we roll the style only on the first render
  42. const [modalStyle] = React.useState(getModalStyle);
  43. const [open, setOpen] = React.useState(true);
  44.  
  45. const handleOpen = () => {
  46. setOpen(true);
  47. };
  48.  
  49. const handleClose = () => {
  50. setOpen(false);
  51. };
  52.  
  53. const body = (
  54. <div style={modalStyle} className={classes.paper}>
  55. <div
  56. className="card"
  57. style={{
  58. fontFamily: "Arial, Helvetica, sans-serif",
  59. borderRadius: "30px",
  60. boxShadow: "0 4px 8px 0 rgba(0,0,0,0.2)",
  61. transition: "0.3s",
  62. textAlign: "center",
  63. alignItems: "center",
  64. padding: "30px",
  65. border: "none",
  66. }}
  67. >
  68. <div style={{ color: "#3D69A8" }}>
  69. <h1 style={{ fontWeight: "bold" }}>Join Quiz</h1>
  70. </div>
  71.  
  72. <div style={{ marginTop: "20px" }}>
  73. <h5>Are you sure to join in this quiz?</h5>
  74. </div>
  75.  
  76. <div style={{ padding: "10px" }}>
  77. <button
  78. onClick={JoinExam}
  79. style={{
  80. fontWeight: "20px",
  81. borderRadius: "10px",
  82. marginTop: "15px",
  83. width: "90px",
  84. height: "50px",
  85. fontSize: "20px",
  86. backgroundColor: "#4067B2",
  87. color: "white",
  88. }}
  89.  
  90. >
  91. YES
  92. </button>
  93. </div>
  94. </div>
  95.  
  96. <div
  97. style={{
  98. marginTop: "-20px",
  99. borderRadius: "30px",
  100. backgroundColor: "#4067B2",
  101. boxShadow: "0 4px 8px 0 rgba(0,0,0,0.2)",
  102. transition: "0.3s",
  103. textAlign: "center",
  104. alignItems: "center",
  105. padding: "10px",
  106. border: "none",
  107. }}
  108. >
  109. <img
  110. onClick={() => closeModal("close")}
  111. src={wrongSign}
  112. style={{
  113. height: "65px",
  114. width: "65px",
  115. margin: "20px 0px",
  116. padding: "5px",
  117. }}
  118. ></img>
  119. </div>
  120.  
  121. </div>
  122. );
  123.  
  124. return (
  125. <div>
  126. <button type="button" onClick={handleOpen}>
  127. Open Modal
  128. </button>
  129. <Modal
  130. open={open}
  131. onClose={handleClose}
  132. aria-labelledby="simple-modal-title"
  133. aria-describedby="simple-modal-description"
  134. >
  135. {body}
  136. </Modal>
  137. </div>
  138. );
  139. };
  140.  
  141. export default JoinModal;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement