Browse Source

responsive listitem

amenpunk 2 years ago
parent
commit
d54aa31f9c

+ 15 - 21
src/Components/MenuMovil.js

@@ -1,42 +1,36 @@
1
-// import {useEffect} from 'react';
2
-// import { Menu, MenuItem } from '@mui/material';
3
-// import {  useNavigate} from "react-router-dom";
4
-
5 1
 import Logo from '../Images/logo.png';
6 2
 import Fade from '@mui/material/Fade';
7 3
 
8
-export function MenuMovil(props) {
4
+import {
5
+    Home, Work,VisibilityOff,PeopleAlt, Equalizer
6
+} from '@mui/icons-material/'
9 7
 
10
-    // const navigate = useNavigate()
11 8
 
12
-    let {  open } =  props;
13
-    console.log(props)
9
+import { NavItem } from '../Components/Navigation/NavItem'
14 10
 
15
-    // useEffect(() => {
16
-    //     console.log('render')
17
-    //     if(!open){
18
-    //         onClose();
19
-    //     }else{
20
-    //         document.getElementById("mySidebar").style.display = "block";
21
-    //     }
22
-    // },[open])
23 11
 
12
+export function MenuMovil(props) {
13
+
14
+    let { open } =  props;
24 15
 
25 16
     return(
26 17
         <Fade 
27 18
             in={open}>
28 19
             <div className="menu-shit w3-sidebar w3-bar-block w3-border-right" id="mySidebar">
29 20
                 <div style={{ flat : 'righ' }} className="sidebar-header">
30
-                    <div className="width_img_mov" style={{  backgroundColor:  "whitesmoke"}}>
21
+                    <div className="width_img_mov">
31 22
                         <img src={Logo} alt="pruebas psicometricas"/>
32 23
                     </div>
33 24
                 </div>
34
-                <a href="/" className="w3-bar-item w3-button">Link 1</a>
35
-                <a href="/" className="w3-bar-item w3-button">Link 2</a>
36
-                <a href="/" className="w3-bar-item w3-button">Link 3</a>
25
+
26
+                <NavItem icon={<Home/>} title="Inicio" route="home" />
27
+                <NavItem icon={<Work/>} title="Puestos" route="puestos" />
28
+                <NavItem icon={<VisibilityOff/>} title="Contraseñas" route="contrasenas" />
29
+                <NavItem icon={<PeopleAlt/>}  title="Expedientes" route="expedientes" />
30
+                <NavItem icon={<Equalizer/>} title="Resultados" route="resultados" />
31
+
37 32
             </div>
38 33
         </Fade>
39 34
     )
40 35
 
41 36
 }
42
-

+ 71 - 0
src/Components/Navigation/MainListItems.jsx

@@ -0,0 +1,71 @@
1
+import React from 'react';
2
+
3
+import { 
4
+    Home, Fingerprint, History, MiscellaneousServices , 
5
+    Work, VisibilityOff, PeopleAlt, Equalizer,
6
+    ExpandLess, ExpandMore
7
+} from '@mui/icons-material/'
8
+
9
+
10
+import { Collapse,ListItem, List ,ListItemIcon,ListItemText,ListSubheader } from '@mui/material/'
11
+import { NavItem } from './NavItem'
12
+
13
+
14
+export function MainListItems(props){
15
+
16
+    const [open, setOpen] = React.useState(false);
17
+
18
+    const showPruebas = () => {
19
+        if(!props.AppBarVisible){
20
+            props.setAppBarVisible(true);
21
+        }
22
+        setOpen(!open);
23
+    };
24
+
25
+    return(
26
+        <List>
27
+
28
+            <ListSubheader inset>MENÚ</ListSubheader>
29
+
30
+            <NavItem icon={<Home/>} title="Inicio" route="home" />
31
+            <NavItem icon={<Work/>} title="Puestos" route="puestos" />
32
+            <NavItem icon={<VisibilityOff/>} title="Contraseñas" route="contrasenas" />
33
+            <NavItem icon={<PeopleAlt/>}  title="Expedientes" route="expedientes" />
34
+            <NavItem icon={<Equalizer/>} title="Resultados" route="resultados" />
35
+
36
+            <ListItem selected={open} onClick={showPruebas}>
37
+                <ListItemIcon>
38
+                    <Fingerprint />
39
+                </ListItemIcon>
40
+
41
+
42
+                <ListItemText 
43
+                    sx={{
44
+                        fontSize: 12,
45
+                        ' .css-10hburv-MuiTypography-root' : {
46
+                            fontSize : '.875rem'
47
+                        },
48
+                    }}
49
+                    primary="Pruebas" 
50
+                />
51
+                {open ? <ExpandLess /> : <ExpandMore />}
52
+            </ListItem>
53
+
54
+
55
+            <Collapse in={open} timeout="auto" unmountOnExit>
56
+                <List component="div" disablePadding>
57
+
58
+                    <NavItem setOpen={setOpen} { ...props} open={open} route="pruebas/crear" title="Crear Prueba" />
59
+                    <NavItem setOpen={setOpen} { ...props} open={open} route="pruebas/listar"  title="Listado de pruebas" />
60
+                    <NavItem setOpen={setOpen} { ...props} open={open} route="pruebas/aplicar"  title="Aplicar" />
61
+                    <NavItem setOpen={setOpen} { ...props} open={open} route="pruebas/respuestas" title="Respuestas" />
62
+                    <NavItem setOpen={setOpen} { ...props} open={open} route="pruebas/calificaciones" title="Calificaciones" />
63
+
64
+                </List>
65
+            </Collapse>
66
+
67
+            <NavItem icon={<MiscellaneousServices/>} title="Configuraciones" route="configuraciones" />
68
+            <NavItem icon={<History/>} title="Historial" route="historial" />
69
+        </List>
70
+    )
71
+}

+ 38 - 0
src/Components/Navigation/NavItem.jsx

@@ -0,0 +1,38 @@
1
+import { useNavigate, useResolvedPath, useMatch } from 'react-router-dom'
2
+import {ListItem, ListItemIcon,ListItemText } from '@mui/material/'
3
+
4
+export function NavItem (props){
5
+
6
+    let navigate = useNavigate()
7
+    let resolved = useResolvedPath(props.route);
8
+    let match = useMatch({ path: resolved.pathname, end: true });
9
+
10
+    let { title, route, icon, open, AppBarVisible, setOpen } = props
11
+
12
+    if(route.startsWith('prueba') && match && open && !AppBarVisible ){
13
+        setOpen(false);
14
+    }
15
+
16
+
17
+    return(
18
+        <ListItem
19
+            sx={{ color : '#25344f'}}
20
+            selected={ match && typeof(match) === "object" }
21
+            onClick={() => navigate(route) } 
22
+            button
23
+        >
24
+            <ListItemIcon>
25
+                {icon && icon}
26
+            </ListItemIcon>
27
+            <ListItemText 
28
+                sx={{
29
+                    fontSize: 12,
30
+                    ' .css-10hburv-MuiTypography-root' : {
31
+                        fontSize : '.875rem'
32
+                    },
33
+                }}
34
+                primary={title} 
35
+                />
36
+        </ListItem>
37
+    )
38
+}

+ 6 - 0
src/Css/all.css

@@ -92,6 +92,8 @@ a:focus {
92 92
     float: left;
93 93
     margin: auto;
94 94
     padding: 11px;
95
+    /* margin-top : 25px; */
96
+    margin-top : 10px;
95 97
 }
96 98
 #sidebar ul.components {
97 99
     padding: 20px 0;
@@ -244,6 +246,10 @@ li.nav-item {
244 246
 .sidebar-header img {
245 247
     width: 100%;
246 248
 }
249
+
250
+.sidebar-header .width_img_mov {
251
+    width: 90%;
252
+}
247 253
 .list-unstyled i{
248 254
     font-size: 14px;
249 255
     margin-right: 10px;