Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3494 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3481 stevensc 1
import React, { useState } from 'react';
2
import { Tabs, Tab, Box } from '@mui/material';
3
 
4
function TabPanel(props) {
5
  const { children, value, index, ...other } = props;
6
 
7
  return (
8
    <div
9
      role='tabpanel'
10
      hidden={value !== index}
11
      id={`simple-tabpanel-${index}`}
12
      aria-labelledby={`simple-tab-${index}`}
13
      {...other}
14
    >
15
      {value === index && <Box sx={{ p: 3 }}>{children}</Box>}
16
    </div>
17
  );
18
}
19
 
20
function TabsAdapter({ tabs }) {
21
  const [value, setValue] = useState(0);
22
 
23
  const handleChange = (event, newValue) => {
24
    setValue(newValue);
25
  };
26
 
27
  return (
28
    <Box sx={{ width: '100%' }}>
29
      <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
30
        <Tabs value={value} onChange={handleChange}>
31
          {tabs.map((tab, index) => (
32
            <Tab key={index} label={tab.label} id={`simple-tab-${index}`} />
33
          ))}
34
        </Tabs>
35
      </Box>
36
      {tabs.map((tab, index) => (
37
        <TabPanel key={index} value={value} index={index}>
38
          {tab.component}
39
        </TabPanel>
40
      ))}
41
    </Box>
42
  );
43
}
44
 
45
export default TabsAdapter;