Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2641 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 2641 Rev 3719
Línea 1... Línea 1...
1
import React from 'react'
1
import React from 'react';
2
import {
-
 
3
  List,
-
 
4
  ListItem,
-
 
5
  ListItemButton,
-
 
6
  ListItemText,
-
 
7
  Typography
-
 
8
} from '@mui/material'
2
import { List, ListItem, ListItemButton, ListItemText, Typography } from '@mui/material';
9
 
3
 
10
import Widget from '../Widget'
4
import Widget from '../Widget';
11
 
5
 
12
const SideMenu = ({
6
const SideMenu = ({
13
  items = [],
7
  items = [],
14
  onChange = null,
8
  onChange = null,
15
  title = '',
9
  title = '',
16
  current = '',
10
  current = '',
17
  defaultValue = '',
11
  defaultValue = '',
18
  defaultLabel = ''
12
  defaultLabel = ''
19
}) => {
13
}) => {
20
  const handleChange = (value) => onChange(value)
14
  const handleChange = (value) => onChange(value);
21
 
15
 
22
  return (
16
  return (
23
    <Widget>
17
    <Widget>
24
      <Widget.Body>
18
      <Widget.Body>
25
        <Typography variant='h2'>{title}</Typography>
19
        <Typography variant='h2'>{title}</Typography>
26
 
20
 
27
        <List sx={{ mt: 1 }}>
21
        <List sx={{ mt: 1 }}>
28
          <ListItemButton
22
          <ListItemButton
29
            sx={{ py: 0, display: defaultLabel ? 'initial' : 'none' }}
23
            sx={{ py: 0, display: defaultLabel ? 'initial' : 'none' }}
30
            onClick={() => handleChange(defaultValue)}
24
            onClick={() => handleChange(defaultValue)}
31
          >
25
          >
32
            <ListItemText
26
            <ListItemText
33
              primary={defaultLabel}
27
              primary={defaultLabel}
34
              primaryTypographyProps={{
28
              slotProps={{
-
 
29
                primary: {
35
                sx: { fontWeight: current === defaultValue ? 'bold' : 'normal' }
30
                  sx: { fontWeight: current === defaultValue ? 'bold' : 'normal' }
-
 
31
                }
36
              }}
32
              }}
37
            />
33
            />
38
          </ListItemButton>
34
          </ListItemButton>
39
          {items.map(({ value, name }) => (
35
          {items.map(({ value, label }) => (
40
            <ListItem key={value} sx={{ p: 0 }}>
36
            <ListItem key={value} sx={{ p: 0 }}>
41
              <ListItemButton
-
 
42
                sx={{ py: 0 }}
-
 
43
                onClick={() => handleChange(value)}
37
              <ListItemButton sx={{ py: 0 }} onClick={() => handleChange(value)}>
44
              >
-
 
45
                <ListItemText
-
 
46
                  id={value}
-
 
47
                  primary={name}
38
                <ListItemText id={value} primary={label} />
48
                  primaryTypographyProps={{
-
 
49
                    sx: { fontWeight: current === value ? 'bold' : 'normal' }
-
 
50
                  }}
-
 
51
                />
-
 
52
              </ListItemButton>
39
              </ListItemButton>
53
            </ListItem>
40
            </ListItem>
54
          ))}
41
          ))}
55
        </List>
42
        </List>
56
      </Widget.Body>
43
      </Widget.Body>
57
    </Widget>
44
    </Widget>
58
  )
45
  );
59
}
46
};
60
 
47
 
61
export default SideMenu
48
export default SideMenu;