浏览代码

mokup to show question at slide in center

amenpunk 2 年之前
父节点
当前提交
35138fc3b8
共有 6 个文件被更改,包括 55 次插入35 次删除
  1. 2 0
      package.json
  2. 0 0
      src/Actions/index.js
  3. 1 0
      src/Actions/types.js
  4. 19 4
      src/App.css
  5. 8 5
      src/Components/Test/Cleaver/Question.jsx
  6. 25 26
      src/Pages/Pruebas/Cleaver.jsx

+ 2 - 0
package.json

@@ -30,10 +30,12 @@
30 30
         "react-dom": "^17.0.2",
31 31
         "react-hot-toast": "^2.2.0",
32 32
         "react-query": "^3.34.12",
33
+        "react-redux": "^8.0.4",
33 34
         "react-router": "6.2.1",
34 35
         "react-router-dom": "6.2.1",
35 36
         "react-scripts": "^5.0.0",
36 37
         "react-scroll": "^1.8.7",
38
+        "redux": "^4.2.0",
37 39
         "web-vitals": "^1.0.1",
38 40
         "yup": "^0.32.11"
39 41
     },

+ 0 - 0
src/Actions/index.js


+ 1 - 0
src/Actions/types.js

@@ -0,0 +1 @@
1
+export const SET_TOKEN = 'SET_TOKEN';

+ 19 - 4
src/App.css

@@ -2,6 +2,10 @@
2 2
   --main: #fd4b4b;
3 3
   --second: #2ec5d3;
4 4
 }
5
+
6
+.main{
7
+    margin-top : 90px !important;
8
+}
5 9
 .App {
6 10
     text-align: center;
7 11
 }
@@ -68,7 +72,7 @@
68 72
 }
69 73
 
70 74
 .MuiContainer-root{
71
-    margin-top : 90px !important;
75
+    /* margin-top : 90px !important; */
72 76
     max-width : 1777px !important;
73 77
     padding : 0px;
74 78
 }
@@ -315,9 +319,8 @@
315 319
   display: flex;
316 320
   flex-direction: column;
317 321
   flex-wrap: wrap;
318
-  align-content: stretch;
319
-  justify-content: flex-start;
320
-  align-items: stretch;
322
+  justify-content: center;
323
+  align-items: center;
321 324
 }
322 325
 
323 326
 .question_btn{
@@ -330,3 +333,15 @@
330 333
 .nextquestion_btn:hover{
331 334
   background-color: var(--main) !important;
332 335
 }
336
+
337
+.card_cleaver_btn{
338
+  margin-right:20px;
339
+  padding-right:20px
340
+}
341
+.question_body{
342
+  display: grid;
343
+}
344
+.question_form{
345
+  grid-column: 1;
346
+  grid-row: 1;
347
+}

+ 8 - 5
src/Components/Test/Cleaver/Question.jsx

@@ -3,7 +3,8 @@ import * as React from 'react';
3 3
 import { Remove as RemoveIcon, Add as AddIcon } from '@mui/icons-material';
4 4
 import {
5 5
   Card,CardContent,Avatar,Checkbox,List,Tooltip,
6
-  ListItem,ListItemButton,ListItemIcon,ListItemText
6
+  ListItem,ListItemButton,ListItemIcon,ListItemText,
7
+  CardActions,Button,Fade,Slide
7 8
 } from '@mui/material'
8 9
 import { deepPurple } from '@mui/material/colors';
9 10
 
@@ -100,19 +101,21 @@ function CheckboxesGroup(props) {
100 101
   );
101 102
 }
102 103
 
103
-export function Question({quiz}) {
104
+export function Question({quiz, index, current}) {
104 105
   let { instrucciondepregunta, respuestas,id } = quiz
106
+  let checked = index ===current;
105 107
   return (
106
-    <Card sx={{ minWidth: 275, margin: '30px !important', borderLeft: '5px solid var(--main)'}}>
108
+    <Fade in={checked} unmountOnExit>
109
+    <Card className="question_form" sx={{ minWidth: 275, margin: '30px !important', borderLeft: '5px solid var(--main)'}}>
107 110
       <CardContent>
108
-
109 111
         <div variant="body2">
110 112
           <List>
111
-            <CheckboxexHeader  group={id} title={instrucciondepregunta}/>
113
+            <CheckboxexHeader  group={index} title={instrucciondepregunta}/>
112 114
           </List>
113 115
           <CheckboxesGroup quiz={respuestas} />
114 116
         </div>
115 117
       </CardContent>
116 118
     </Card>
119
+    </Fade>
117 120
   );
118 121
 }

+ 25 - 26
src/Pages/Pruebas/Cleaver.jsx

@@ -2,19 +2,20 @@ import React, { useMemo } from 'react'
2 2
 import { Service } from '../../Utils/HTTP'
3 3
 import useAuth from '../../Auth/useAuth.js';
4 4
 import { Question } from '../../Components/Test/Cleaver/Question.jsx'
5
-import { Box,Button, Collapse, List } from '@mui/material'
5
+import { Box,Button, Collapse, List, Slide } from '@mui/material'
6 6
 import { TransitionGroup } from 'react-transition-group';
7
-import * as Scroll from 'react-scroll';
7
+// import * as Scroll from 'react-scroll';
8 8
 
9 9
 export function Cleaver() {
10 10
 
11
-var scroll = Scroll.animateScroll;
11
+// var scroll = Scroll.animateScroll;
12 12
 
13 13
   let auth = useAuth();
14 14
   let token = useMemo(() => auth.getToken(), [auth])
15 15
 
16 16
   const [totalRespondidas, setRespondidas] = React.useState([]);
17 17
   const [totalPreguntas, setPreguntas] = React.useState([]);
18
+  const [current, setCurrent] = React.useState(0);
18 19
 
19 20
 
20 21
   React.useEffect(() => {
@@ -28,38 +29,27 @@ var scroll = Scroll.animateScroll;
28 29
   }, [token]);
29 30
 
30 31
   const handleAddQuestion = () => {
31
-    let op = { smooth: true, duration: 200, delay :1, offset :20}
32
-    scroll.scrollToBottom(op);
32
+    // let op = { smooth: true, duration: 200, delay :1, offset :20}
33
+    // scroll.scrollToBottom(op);
33 34
     let currentAnswer  = totalRespondidas[totalRespondidas.length - 1];
34 35
     const nextHiddenItem = totalPreguntas.filter(({id}) => id !== currentAnswer.id );
35 36
     if (nextHiddenItem) {
36 37
       setPreguntas(nextHiddenItem);
37 38
       let temp = nextHiddenItem.shift()
38 39
       setRespondidas([...totalRespondidas,temp]);
40
+      setCurrent(current+1);
39 41
     }
40
-
41
-    // console.log("RESPONDIDAS: ", totalRespondidas.length)
42
-    // console.log("RESTANTES: ", totalPreguntas.length)
43 42
   };
44 43
 
45 44
   return (
46
-
47 45
     <div  className="content-section question">
48
-      <div className="main">
49
-        <Box sx={{ mt: 1 }}>
50
-          <List >
51
-            <TransitionGroup >
52
-              {totalRespondidas.map((item) => (
53
-                <Collapse key={item.id} >
54
-                  <Question key={item.id} id={item.id} quiz={item} />
55
-                </Collapse>
56
-              ))
57
-            }
58
-            </TransitionGroup>
59
-          </List>
60
-        </Box>
46
+      <Box className="question_body">
47
+        {totalRespondidas.map((item,i) => (
48
+          <Question key={item.id} id={item.id} quiz={item} index={i} current={current} /> )
49
+        )}
50
+      </Box>
61 51
 
62
-        <div className="question_btn">
52
+      <div className="question_btn">
63 53
         <Button
64 54
           className="nextquestion_btn"
65 55
           sx={{ backgroundColor: 'var(--main)' }}
@@ -67,12 +57,21 @@ var scroll = Scroll.animateScroll;
67 57
           disabled={totalPreguntas.length <= 0}
68 58
           onClick={handleAddQuestion}
69 59
         >
70
-            Siguiente Pregunta
60
+          Anterior
61
+        </Button>
62
+        <Button
63
+          className="nextquestion_btn"
64
+          sx={{ backgroundColor: 'var(--main)' }}
65
+          variant="contained"
66
+          disabled={totalPreguntas.length <= 0}
67
+          onClick={handleAddQuestion}
68
+        >
69
+          Siguiente
71 70
         </Button>
72
-          </div>
73
-
74 71
       </div>
75 72
     </div>
76 73
   )
77 74
 
78 75
 }
76
+
77
+