Browse Source

mokup to show question at slide in center

amenpunk 2 years ago
parent
commit
35138fc3b8

+ 2 - 0
package.json

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

+ 0 - 0
src/Actions/index.js


+ 1 - 0
src/Actions/types.js

1
+export const SET_TOKEN = 'SET_TOKEN';

+ 19 - 4
src/App.css

2
   --main: #fd4b4b;
2
   --main: #fd4b4b;
3
   --second: #2ec5d3;
3
   --second: #2ec5d3;
4
 }
4
 }
5
+
6
+.main{
7
+    margin-top : 90px !important;
8
+}
5
 .App {
9
 .App {
6
     text-align: center;
10
     text-align: center;
7
 }
11
 }
68
 }
72
 }
69
 
73
 
70
 .MuiContainer-root{
74
 .MuiContainer-root{
71
-    margin-top : 90px !important;
75
+    /* margin-top : 90px !important; */
72
     max-width : 1777px !important;
76
     max-width : 1777px !important;
73
     padding : 0px;
77
     padding : 0px;
74
 }
78
 }
315
   display: flex;
319
   display: flex;
316
   flex-direction: column;
320
   flex-direction: column;
317
   flex-wrap: wrap;
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
 .question_btn{
326
 .question_btn{
330
 .nextquestion_btn:hover{
333
 .nextquestion_btn:hover{
331
   background-color: var(--main) !important;
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
 import { Remove as RemoveIcon, Add as AddIcon } from '@mui/icons-material';
3
 import { Remove as RemoveIcon, Add as AddIcon } from '@mui/icons-material';
4
 import {
4
 import {
5
   Card,CardContent,Avatar,Checkbox,List,Tooltip,
5
   Card,CardContent,Avatar,Checkbox,List,Tooltip,
6
-  ListItem,ListItemButton,ListItemIcon,ListItemText
6
+  ListItem,ListItemButton,ListItemIcon,ListItemText,
7
+  CardActions,Button,Fade,Slide
7
 } from '@mui/material'
8
 } from '@mui/material'
8
 import { deepPurple } from '@mui/material/colors';
9
 import { deepPurple } from '@mui/material/colors';
9
 
10
 
100
   );
101
   );
101
 }
102
 }
102
 
103
 
103
-export function Question({quiz}) {
104
+export function Question({quiz, index, current}) {
104
   let { instrucciondepregunta, respuestas,id } = quiz
105
   let { instrucciondepregunta, respuestas,id } = quiz
106
+  let checked = index ===current;
105
   return (
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
       <CardContent>
110
       <CardContent>
108
-
109
         <div variant="body2">
111
         <div variant="body2">
110
           <List>
112
           <List>
111
-            <CheckboxexHeader  group={id} title={instrucciondepregunta}/>
113
+            <CheckboxexHeader  group={index} title={instrucciondepregunta}/>
112
           </List>
114
           </List>
113
           <CheckboxesGroup quiz={respuestas} />
115
           <CheckboxesGroup quiz={respuestas} />
114
         </div>
116
         </div>
115
       </CardContent>
117
       </CardContent>
116
     </Card>
118
     </Card>
119
+    </Fade>
117
   );
120
   );
118
 }
121
 }

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

2
 import { Service } from '../../Utils/HTTP'
2
 import { Service } from '../../Utils/HTTP'
3
 import useAuth from '../../Auth/useAuth.js';
3
 import useAuth from '../../Auth/useAuth.js';
4
 import { Question } from '../../Components/Test/Cleaver/Question.jsx'
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
 import { TransitionGroup } from 'react-transition-group';
6
 import { TransitionGroup } from 'react-transition-group';
7
-import * as Scroll from 'react-scroll';
7
+// import * as Scroll from 'react-scroll';
8
 
8
 
9
 export function Cleaver() {
9
 export function Cleaver() {
10
 
10
 
11
-var scroll = Scroll.animateScroll;
11
+// var scroll = Scroll.animateScroll;
12
 
12
 
13
   let auth = useAuth();
13
   let auth = useAuth();
14
   let token = useMemo(() => auth.getToken(), [auth])
14
   let token = useMemo(() => auth.getToken(), [auth])
15
 
15
 
16
   const [totalRespondidas, setRespondidas] = React.useState([]);
16
   const [totalRespondidas, setRespondidas] = React.useState([]);
17
   const [totalPreguntas, setPreguntas] = React.useState([]);
17
   const [totalPreguntas, setPreguntas] = React.useState([]);
18
+  const [current, setCurrent] = React.useState(0);
18
 
19
 
19
 
20
 
20
   React.useEffect(() => {
21
   React.useEffect(() => {
28
   }, [token]);
29
   }, [token]);
29
 
30
 
30
   const handleAddQuestion = () => {
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
     let currentAnswer  = totalRespondidas[totalRespondidas.length - 1];
34
     let currentAnswer  = totalRespondidas[totalRespondidas.length - 1];
34
     const nextHiddenItem = totalPreguntas.filter(({id}) => id !== currentAnswer.id );
35
     const nextHiddenItem = totalPreguntas.filter(({id}) => id !== currentAnswer.id );
35
     if (nextHiddenItem) {
36
     if (nextHiddenItem) {
36
       setPreguntas(nextHiddenItem);
37
       setPreguntas(nextHiddenItem);
37
       let temp = nextHiddenItem.shift()
38
       let temp = nextHiddenItem.shift()
38
       setRespondidas([...totalRespondidas,temp]);
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
   return (
44
   return (
46
-
47
     <div  className="content-section question">
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
         <Button
53
         <Button
64
           className="nextquestion_btn"
54
           className="nextquestion_btn"
65
           sx={{ backgroundColor: 'var(--main)' }}
55
           sx={{ backgroundColor: 'var(--main)' }}
67
           disabled={totalPreguntas.length <= 0}
57
           disabled={totalPreguntas.length <= 0}
68
           onClick={handleAddQuestion}
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
         </Button>
70
         </Button>
72
-          </div>
73
-
74
       </div>
71
       </div>
75
     </div>
72
     </div>
76
   )
73
   )
77
 
74
 
78
 }
75
 }
76
+
77
+