Browse Source

table style refactor

amenpunk 3 years ago
parent
commit
352d6c076a

+ 7 - 2
src/App.css

@@ -43,8 +43,8 @@
43 43
 
44 44
 .Mui-selected{
45 45
     /* se desahilito para la tabla de password */
46
-    /* color : #FFF !important; */
47
-    /* background-color : #fd4b4b !important; */
46
+    color : #FFF !important;
47
+    background-color : #fd4b4b !important;
48 48
     /* background-color : rgba(253, 75, 75, 0.1) !important; */
49 49
 }
50 50
 
@@ -205,3 +205,8 @@
205 205
     padding-top: 10px;
206 206
     align-items: baseline !important;
207 207
 }
208
+
209
+.contras_operation{
210
+    display : flex;
211
+    flex-direction:row;
212
+}

+ 58 - 0
src/Components/Password/Header.jsx

@@ -0,0 +1,58 @@
1
+import { encabezados } from './Rows';
2
+import { visuallyHidden } from '@mui/utils';
3
+
4
+import { 
5
+    TableHead, TableRow, TableCell,
6
+    Checkbox, TableSortLabel, Box,
7
+    // IconButton,Typography,Toolbar, Tooltip
8
+} from '@mui/material'
9
+
10
+
11
+export function TableHeadCustom(props){
12
+    
13
+    const { onSelectAllClick, order, orderBy, numSelected, rowCount, onRequestSort } = props;
14
+    const createSortHandler = (property) => (event) => {
15
+        onRequestSort(event, property);
16
+    };
17
+
18
+    return (
19
+        <TableHead>
20
+            <TableRow>
21
+                <TableCell padding="checkbox">
22
+                    <Checkbox
23
+                        color="primary"
24
+                        indeterminate={numSelected > 0 && numSelected < rowCount}
25
+                        checked={rowCount > 0 && numSelected === rowCount}
26
+                        onChange={onSelectAllClick}
27
+                        inputProps={{
28
+                            'aria-label': 'select all desserts',
29
+                        }}
30
+                    />
31
+                </TableCell>
32
+                { encabezados.map( (headCell, index) => (
33
+                    <TableCell
34
+                        key={index}
35
+                        align={headCell.numeric ? 'right' : 'left'}
36
+                        padding={headCell.disablePadding ? 'none' : 'normal'}
37
+                        sortDirection={orderBy === headCell.id ? order : false}
38
+                    >
39
+                        <TableSortLabel
40
+                            style={{ fontWeight:'bold' }}
41
+                            active={orderBy === headCell.id}
42
+                            direction={orderBy === headCell.id ? order : 'asc'}
43
+                            onClick={createSortHandler(headCell.id)}
44
+                        >
45
+                            {headCell.label}
46
+                            {orderBy === headCell.id ? (
47
+                                <Box component="span" sx={visuallyHidden}>
48
+                                    {order === 'desc' ? 'sorted descending' : 'sorted ascending'}
49
+                                </Box>
50
+                            ) : null}
51
+                        </TableSortLabel>
52
+                    </TableCell>
53
+                ))}
54
+            </TableRow>
55
+        </TableHead>
56
+    );
57
+
58
+}

+ 71 - 0
src/Components/Password/HeaderOperation.jsx

@@ -0,0 +1,71 @@
1
+import { 
2
+    IconButton,Typography,Toolbar,
3
+    Tooltip
4
+} from '@mui/material'
5
+
6
+import { alpha } from '@mui/material/styles';
7
+
8
+import {
9
+    Delete as DeleteIcon,
10
+    Add as AddIcon,
11
+    ManageSearch as SearchIcon,
12
+} from '@mui/icons-material/'
13
+
14
+export const TableEncabezadoOperation = (props) => {
15
+    const { numSelected } = props;
16
+
17
+    return (
18
+        <Toolbar
19
+            sx={{
20
+                pl: { sm: 2 },
21
+                pr: { xs: 1, sm: 1 },
22
+                ...(numSelected > 0 && {
23
+                    bgcolor: (theme) =>
24
+                        alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity),
25
+                }),
26
+            }}
27
+        >
28
+            {numSelected > 0 ? (
29
+                <Typography
30
+                    sx={{ flex: '1 1 100%' }}
31
+                    color="inherit"
32
+                    variant="subtitle1"
33
+                    component="div"
34
+                >
35
+                    {numSelected} Seleccionados
36
+                </Typography>
37
+            ) : (
38
+                    <Typography
39
+                        sx={{ flex: '1 1 100%' }}
40
+                        variant="h6"
41
+                        id="tableTitle"
42
+                        component="div"
43
+                    >
44
+                        Contraseñas
45
+                    </Typography>
46
+                )}
47
+
48
+            {numSelected > 0 ? (
49
+                <Tooltip title="Elimnar">
50
+                    <IconButton>
51
+                        <DeleteIcon />
52
+                    </IconButton>
53
+                </Tooltip>
54
+            ) : (
55
+                    <div className="contras_operation">
56
+                        <Tooltip title="Buscar">
57
+                            <IconButton>
58
+                                <SearchIcon />
59
+                            </IconButton>
60
+                        </Tooltip>
61
+                        <Tooltip title="Agregar">
62
+                            <IconButton onClick={() => console.log('click')}>
63
+                                <AddIcon />
64
+                            </IconButton>
65
+                        </Tooltip>
66
+                    </div>
67
+                )}
68
+        </Toolbar>
69
+    );
70
+
71
+}

+ 0 - 120
src/Components/Password/config.js

@@ -1,19 +1,3 @@
1
-import { 
2
-    TableHead, TableRow, TableCell,
3
-    Checkbox, TableSortLabel, Box,
4
-    IconButton,Typography,Toolbar,
5
-    Tooltip
6
-} from '@mui/material'
7
-
8
-import { alpha } from '@mui/material/styles';
9
-import { visuallyHidden } from '@mui/utils';
10
-import { encabezados } from './Rows';
11
-
12
-import {
13
-    Delete as DeleteIcon,
14
-    FilterList as FilterListIcon,
15
-} from '@mui/icons-material/'
16
-
17 1
 export const rows = [
18 2
     createData('Cupcake', 305, 'Analista',109238109238, 'SI', 'SI', 'Nice', 'Good'),
19 3
 ]
@@ -34,61 +18,6 @@ export const action_icon =  {
34 18
     margin :5
35 19
 }
36 20
 
37
-export const TableEncabezadoOperation = (props) => {
38
-
39
-    const { numSelected } = props;
40
-
41
-    return (
42
-        <Toolbar
43
-            sx={{
44
-                pl: { sm: 2 },
45
-                pr: { xs: 1, sm: 1 },
46
-                ...(numSelected > 0 && {
47
-                    bgcolor: (theme) =>
48
-                        alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity),
49
-                }),
50
-            }}
51
-        >
52
-            {numSelected > 0 ? (
53
-                <Typography
54
-                    sx={{ flex: '1 1 100%' }}
55
-                    color="inherit"
56
-                    variant="subtitle1"
57
-                    component="div"
58
-                >
59
-                    {numSelected} Seleccionados
60
-                </Typography>
61
-            ) : (
62
-                    <Typography
63
-                        sx={{ flex: '1 1 100%' }}
64
-                        variant="h6"
65
-                        id="tableTitle"
66
-                        component="div"
67
-                    >
68
-                        Contraseñas
69
-                    </Typography>
70
-                )}
71
-
72
-            {numSelected > 0 ? (
73
-                <Tooltip title="Elimnar">
74
-                    <IconButton>
75
-                        <DeleteIcon />
76
-                    </IconButton>
77
-                </Tooltip>
78
-            ) : (
79
-                    <Tooltip title="Buscar">
80
-                        <IconButton>
81
-                            <FilterListIcon />
82
-                        </IconButton>
83
-                    </Tooltip>
84
-                )}
85
-        </Toolbar>
86
-    );
87
-
88
-}
89
-
90
-
91
-
92 21
 export function createData( pass, nivel, puesto, cui, uso, picture, cv, replic, ope) {
93 22
     return {
94 23
         pass,
@@ -130,52 +59,3 @@ export function Cuerpo(array, comparator) {
130 59
     });
131 60
     return stabilizedThis.map((el) => el[0]);
132 61
 }
133
-
134
-export function EnhancedTableHead(props){
135
-    // header de la tabla
136
-    
137
-    const { onSelectAllClick, order, orderBy, numSelected, rowCount, onRequestSort } = props;
138
-    const createSortHandler = (property) => (event) => {
139
-        onRequestSort(event, property);
140
-    };
141
-
142
-    return (
143
-        <TableHead>
144
-            <TableRow>
145
-                <TableCell padding="checkbox">
146
-                    <Checkbox
147
-                        color="primary"
148
-                        indeterminate={numSelected > 0 && numSelected < rowCount}
149
-                        checked={rowCount > 0 && numSelected === rowCount}
150
-                        onChange={onSelectAllClick}
151
-                        inputProps={{
152
-                            'aria-label': 'select all desserts',
153
-                        }}
154
-                    />
155
-                </TableCell>
156
-                { encabezados.map( (headCell, index) => (
157
-                    <TableCell
158
-                        key={index}
159
-                        align={headCell.numeric ? 'right' : 'left'}
160
-                        padding={headCell.disablePadding ? 'none' : 'normal'}
161
-                        sortDirection={orderBy === headCell.id ? order : false}
162
-                    >
163
-                        <TableSortLabel
164
-                            style={{ fontWeight:'bold' }}
165
-                            active={orderBy === headCell.id}
166
-                            direction={orderBy === headCell.id ? order : 'asc'}
167
-                            onClick={createSortHandler(headCell.id)}
168
-                        >
169
-                            {headCell.label}
170
-                            {orderBy === headCell.id ? (
171
-                                <Box component="span" sx={visuallyHidden}>
172
-                                    {order === 'desc' ? 'sorted descending' : 'sorted ascending'}
173
-                                </Box>
174
-                            ) : null}
175
-                        </TableSortLabel>
176
-                    </TableCell>
177
-                ))}
178
-            </TableRow>
179
-        </TableHead>
180
-    );
181
-}

+ 8 - 7
src/Pages/Contras.jsx

@@ -7,10 +7,12 @@ import {
7 7
     action_icon,
8 8
     Comparar,
9 9
     Cuerpo,
10
-    EnhancedTableHead,
11
-    TableEncabezadoOperation
10
+    // TableEncabezadoOperation
12 11
 } from '../Components/Password/config.js';
13 12
 
13
+import { TableHeadCustom as TableHead } from '../Components/Password/Header'
14
+import { TableEncabezadoOperation as TableOperation } from '../Components/Password/HeaderOperation.jsx'
15
+
14 16
 import { 
15 17
     Table, TableBody, TableCell, TableContainer, 
16 18
     TableRow, TablePagination,
@@ -86,17 +88,16 @@ export function Contras() {
86 88
                 <Box sx={{ width: '100%' }}>
87 89
                     <Paper sx={{ width: '100%', mb: 2 }}>
88 90
 
89
-                        <TableEncabezadoOperation numSelected={selected.length} />
91
+                        <TableOperation numSelected={selected.length} />
90 92
 
91 93
                         <TableContainer>
92 94
 
93 95
                             <Table
94 96
                                 sx={{ minWidth: 750 }}
95
-                                aria-labelledby="Contrasenas"
96
-                                size={dense ? 'small' : 'medium'} 
97
-                            >
97
+                                aria-labelledby=""
98
+                                size={dense ? 'small' : 'medium'} >
98 99
 
99
-                                <EnhancedTableHead
100
+                                <TableHead
100 101
                                     numSelected={selected.length}
101 102
                                     order={order}
102 103
                                     orderBy={orderBy}