Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 1542 | Rev 1544 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1542 Rev 1543
Línea 1... Línea 1...
1
import React, { useState } from 'react'
1
import React from 'react'
2
import {
2
import {
3
  List,
3
  List,
4
  ListItem,
4
  ListItem,
5
  ListItemButton,
5
  ListItemButton,
6
  ListItemText,
6
  ListItemText,
7
  Typography
7
  Typography
8
} from '@mui/material'
8
} from '@mui/material'
Línea 9... Línea 9...
9
 
9
 
Línea 10... Línea 10...
10
import WidgetWrapper from 'components/widgets/WidgetLayout'
10
import WidgetWrapper from 'components/widgets/WidgetLayout'
11
 
11
 
12
const SideMenu = ({ items = [], onChange = null, title = '' }) => {
-
 
13
  const [currentIndex, setCurrentIndex] = useState(0)
12
const SideMenu = ({
14
 
13
  items = [],
15
  const handleChange = (index, value) => {
14
  onChange = null,
16
    setCurrentIndex(index)
15
  title = '',
-
 
16
  current = ''
Línea 17... Línea 17...
17
    onChange(value)
17
}) => {
18
  }
18
  const handleChange = (value) => onChange(value)
19
 
19
 
Línea 20... Línea 20...
20
  return (
20
  return (
21
    <WidgetWrapper p={1}>
21
    <WidgetWrapper p={1}>
22
      <Typography variant='h2'>{title}</Typography>
22
      <Typography variant='h2'>{title}</Typography>
23
 
23
 
24
      <List sx={{ mt: 1 }}>
24
      <List sx={{ mt: 1 }}>
25
        {items.map(({ value, name }, index) => (
25
        {items.map(({ value, name }) => (
26
          <ListItem key={value} sx={{ p: 0 }}>
26
          <ListItem key={value} sx={{ p: 0 }}>
-
 
27
            <ListItemButton sx={{ py: 0 }} onClick={() => handleChange(value)}>
-
 
28
              <ListItemText
27
            <ListItemButton onClick={() => handleChange(index, value)}>
29
                id={value}
-
 
30
                primary={name}
-
 
31
                sx={{
28
              <ListItemText
32
                  '& MuiListItemText-primary': {
29
                id={value}
33
                    fontWeight: current === value ? 'bold' : 'normal'
30
                primary={name}
34
                  }
31
                sx={{ fontWeight: currentIndex === index ? 'bold' : 'normal' }}
35
                }}
32
              />
36
              />